Thor

#include<bits/stdc++.h>
using namespace std;
#define
#define
#define
#define
#define
#define
#define
#define
#define
#define
#define
#define
#define
#define
#define
#define
#define
#define
#define
#define
#define
#define
#define
#define
#define
For(j,m-1) cout<<a[i][j]<<' ';\
cout<<a[i][m]<<endl; \
}
#pragma
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
ll mul(ll a,ll b){return (a*b)%F;}
ll add(ll a,ll b){return (a+b)%F;}
ll sub(ll a,ll b){return ((a-b)%F+F)%F;}
void upd(ll &a,ll b){a=(a%F+b%F)%F;}
int read()
{
int x=0,f=1; char ch=getchar();
while(!isdigit(ch)) {if (ch=='-') f=-1; ch=getchar();}
while(isdigit(ch)) { x=x*10+ch-'0'; ch=getchar();}
return x*f;
}
int n,q;
#define
int l[MAXN],r[MAXN];
vi a[MAXN];
int b[MAXN]={0};
int main()
{
// freopen("A.in","r",stdin);
// freopen(".out","w",stdout);
n=read(),q=read();
MEM(a) MEM(l) MEM(r)
int siz=1,ans=0; l[1]=0; r[0]=1;
int idx=1;
For(i,q) {
int p=read(),c=read();
if (p==1) {
siz++; b[siz-1]=1;
a[c].pb(siz-1); ++ans;
} else if (p==2) {
int sz=a[c].size();
Rep(j,sz) {
int p=a[c][j];
if (!b[p]) continue;
b[p]=0;
--ans;
}
a[c].clear();
} else {
Fork(j,idx,c) {
if (b[j]) {
b[j]=0; ans--;
}
}
idx=max(idx,c);
}
cout<<ans<<endl;
}

return 0;
}

Ant Man