#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
#define ios cin.tie(0), ios::sync_with_stdio(false)
#define f first
#define s second
const int maxN = 3e5;
signed main(){
// ios;
int n, q;
cin >> n >> q;
set<int> st[maxN];
int zero = n;
// cout << 1 << endl;
for(int i = 0; i < q; i++){
int ty;
cin >> ty;
if(ty == 1){
int u, v;
cin >> u >> v;
if(!st[v].size()) zero--;
if(!st[u].size()) zero--;
st[u].insert(v);
st[v].insert(u);
}else if(ty == 2){
int v;
cin >> v;
if(st[v].size()){
for(auto i: st[v]){
st[i].erase(v);
if(!st[i].size()) zero++;
}
st[v].clear();
zero++;
}
}
cout << zero << endl;
}
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CiNkZWZpbmUgbGwgbG9uZyBsb25nCiNkZWZpbmUgZW5kbCAnXG4nCiNkZWZpbmUgaW9zIGNpbi50aWUoMCksIGlvczo6c3luY193aXRoX3N0ZGlvKGZhbHNlKQojZGVmaW5lIGYgZmlyc3QKI2RlZmluZSBzIHNlY29uZApjb25zdCBpbnQgbWF4TiA9IDNlNTsKc2lnbmVkIG1haW4oKXsKICAgIC8vIGlvczsKICAgIGludCBuLCBxOwogICAgY2luID4+IG4gPj4gcTsKICAgIHNldDxpbnQ+IHN0W21heE5dOwogICAgaW50IHplcm8gPSBuOwogICAgLy8gY291dCA8PCAxIDw8IGVuZGw7CiAgICBmb3IoaW50IGkgPSAwOyBpIDwgcTsgaSsrKXsKICAgICAgICBpbnQgdHk7CiAgICAgICAgY2luID4+IHR5OwogICAgICAgIGlmKHR5ID09IDEpewogICAgICAgICAgICBpbnQgdSwgdjsKICAgICAgICAgICAgY2luID4+IHUgPj4gdjsKICAgICAgICAgICAgaWYoIXN0W3ZdLnNpemUoKSkgemVyby0tOwogICAgICAgICAgICBpZighc3RbdV0uc2l6ZSgpKSB6ZXJvLS07IAogICAgICAgICAgICBzdFt1XS5pbnNlcnQodik7CiAgICAgICAgICAgIHN0W3ZdLmluc2VydCh1KTsKICAgICAgICAgICAgCiAgICAgICAgfWVsc2UgaWYodHkgPT0gMil7CiAgICAgICAgICAgIGludCB2OyAKICAgICAgICAgICAgY2luID4+IHY7CiAgICAgICAgICAgIGlmKHN0W3ZdLnNpemUoKSl7CiAgICAgICAgICAgICAgIGZvcihhdXRvIGk6IHN0W3ZdKXsKICAgICAgICAgICAgICAgICAgIHN0W2ldLmVyYXNlKHYpOyAKICAgICAgICAgICAgICAgICAgIGlmKCFzdFtpXS5zaXplKCkpIHplcm8rKzsKICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICBzdFt2XS5jbGVhcigpOwogICAgICAgICAgICAgICB6ZXJvKys7CiAgICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgY291dCA8PCB6ZXJvIDw8IGVuZGw7CiAgICB9Cgp9CiAgICAgICAgICAgICAgIA==