#include #include using namespace std; const int N=5e6+10; int a[N]; int fa[N]; int len[N]; int find(int x) { if(x!=fa[x]) return fa[x]=find(fa[x]); return x; } void link(int x,int y) { int xx=find(y); int yy=find(x); if(xx>yy) swap(xx,yy); fa[yy]=xx; } int read() { int ans=0; char c=getchar(); while(c=='\n'||c==' ') c=getchar(); while(c>='0'&&c<='9') ans=ans*10+c-'0',c=getchar(); return ans; } int main() { int n,f,x; cin>>n; for(int i=1;i<=n;i++) fa[i]=i; for(int i=1;i<=n;i++) { f=read(); x=read(); if(f==1) { if(a[x]) continue; a[x]=1; len[x]=1; if(a[x+1]==1) link(x,x+1),len[x]+=len[x+1]; if(a[x-1]==1) link(x-1,x),len[find(x-1)]+=len[x]; } else { int ans=0; if(x==len[1]+1) ans=len[1]+1+len[x+1]+1; else ans=len[1]+1; printf("%d\n",ans); } } }