#include<iostream>#include<cmath>#include<cstring>#include<cstdio>#include<algorithm>usingnamespacestd;
constint maxn=300005;
int f[maxn],d[maxn],b[maxn],c[maxn],a[maxn],n,m,i,t,j,k,l,x,y,tot,ans;
int main(){
// freopen("data.in","r",stdin);freopen("data.out","w",stdout);scanf("%d%d",&n,&m);tot=1;
for (i=1;i<=m;i++){
scanf("%d%d",&x,&y);
if (x==1) d[++d[0]]=y,c[y]=d[0],a[y]++,ans++;
elseif (x==2) b[y]=c[y],ans-=a[y],a[y]=0;
else{
for (j=tot;j<=y;j++)
if (b[d[j]]<j) a[d[j]]--,ans--,b[d[j]]=j;
tot=max(tot,y+1);
}
printf("%d\n",ans);
}
}