#include<bits/stdc++.h>
using namespace std;
int main(){
int N,Q;
cin >> N >> Q;
vector<int>cnt(N,1);
set<pair<int,int>>s;
for(int i=0;i<N;i++)s.insert({i,i});
s.insert({-1,2e9});
s.insert({N,2e9});
while(Q--){
int t;
cin >> t;
if(t==1){
int x,c;
cin >> x >> c;
x--,c--;
auto it=s.lower_bound({x,2e9});
auto[R,Rc]=*it;
auto[L,Mc]=*--it;
auto[_,Lc]=*--it;
cnt[Mc]-=R-L;
cnt[c]+=R-L;
it++;
it=s.erase(it);//[R,Rc]
if(c==Rc){
it=s.erase(it);
}
if(c==Lc){
//pass
}else{
s.insert({L,c});
}
}else{
int c;
cin >> c;
c--;
cout << cnt[c] << endl;
}
}
}
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCmludCBtYWluKCl7CglpbnQgTixROwoJY2luID4+IE4gPj4gUTsKCXZlY3RvcjxpbnQ+Y250KE4sMSk7CglzZXQ8cGFpcjxpbnQsaW50Pj5zOwoJZm9yKGludCBpPTA7aTxOO2krKylzLmluc2VydCh7aSxpfSk7CglzLmluc2VydCh7LTEsMmU5fSk7CglzLmluc2VydCh7TiwyZTl9KTsKCQoJd2hpbGUoUS0tKXsKCQlpbnQgdDsKCQljaW4gPj4gdDsKCQlpZih0PT0xKXsKCQkJaW50IHgsYzsKCQkJY2luID4+IHggPj4gYzsKCQkJeC0tLGMtLTsKCQkJYXV0byBpdD1zLmxvd2VyX2JvdW5kKHt4LDJlOX0pOwoJCQlhdXRvW1IsUmNdPSppdDsKCQkJYXV0b1tMLE1jXT0qLS1pdDsKCQkJYXV0b1tfLExjXT0qLS1pdDsKCQkJY250W01jXS09Ui1MOwoJCQljbnRbY10rPVItTDsKCQkJaXQrKzsKCQkJaXQ9cy5lcmFzZShpdCk7Ly9bUixSY10KCQkJaWYoYz09UmMpewoJCQkJaXQ9cy5lcmFzZShpdCk7CgkJCX0KCQkJaWYoYz09TGMpewoJCQkJLy9wYXNzCgkJCX1lbHNlewoJCQkJcy5pbnNlcnQoe0wsY30pOwoJCQl9CgkJfWVsc2V7CgkJCWludCBjOwoJCQljaW4gPj4gYzsKCQkJYy0tOwoJCQljb3V0IDw8IGNudFtjXSA8PCBlbmRsOwoJCX0KCX0KfQo=