/*
    Nintai-ryoku ga ari, jikan ga kakaru purosesu o shinrai suru 
                                        ~ 死神
*/

#include <bits/stdc++.h>
/*
#include<boost/multiprecision/cpp_int.hpp>
namespace mp=boost::multiprecision;
*/
using namespace std;

/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!shortcuts!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
#define ll                          long long 
// #define ll                          int
#define lo                          mp::cpp_int
#define pb                          push_back
#define pob                         pop_back
#define mk                          make_pair
#define endl                        "\n"                       
#define ce(x)                       cout<<x<<"\n";
#define fill(s,v)                   memset(s,v,sizeof(s))
#define speed                       {ios_base::sync_with_stdio(false); cin.tie(0); }
#define deb(x)                      cout<<#x<<" "<<x<<endl; 
#define ull                         unsigned long long int
#define in(a)                       ll a; cin>>a;
#define in2(a,b)                    ll a,b; cin>>a>>b;
#define in3(a,b,c)                  ll a,b,c; cin>>a>>b>>c;
#define in4(a,b,c,d)                ll a,b,c,d; cin>>a>>b>>c>>d;
#define in5(a,b,c,d,e)              ll a,b,c,d,e; cin>>a>>b>>c>>d>>e;
#define YES                         cout<<"YES"<<endl;
#define Yes                         cout<<"Yes"<<endl;
#define NO                          cout<<"NO"<<endl;
#define No                          cout<<"No"<<endl;
#define yes                         cout<<"yes"<<endl;
#define no                          cout<<"no"<<endl;
#define take(a,n)                   for(ll pp=0;pp<n;pp++) { cin>>a[pp]; }
#define take2(a,n)                  for(ll p=0;p<n;p++) { ll temp;cin>>temp;a.pb(temp); }
#define f(i,n)                      for(ll i=0;i<n;i++)
#define f1(i,a,n)                   for(ll i=a;i<n;i++)
#define show(x)                     for(auto t:x)cout<<t<<" ";
// #define show(a,n) for(ll p=0;p<n;p++) cout<<a[p]<<" ";
#define _                           <<" "<<
#define nl                          cout<<endl;
#define sq(x)                       ((x)*(x))
#define call(v)                     v.begin(),v.end()
#define rall(v)                     v.rbegin(),v.rend()
#define ff                          first
#define ss                          second
#define ld                          long double
#define dekh_lo                     cout<<"dekh_lo"<<endl;
#define de2(x,y)                    cout<<#x<<" = "<<(x) <<' '<< #y<<" = "<<y<<endl;typedef pair<ll,ll> pii;
#define copy(b,a,n)                 for(ll i=0;i<n;i++) b[i]=a[i];
#define lelo(b)                     for(auto &i:b)cin>>i;
#define tc(tt) \
    ll tt;    \
    cin>>tt; \
    for(ll _tt=0;_tt<tt; _tt++) 

/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!data-structures!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
typedef vector<vector<ll>> matrix ;  
typedef pair<ll,ll> pii;
typedef vector<pii> vii;
typedef vector<ll> vi;   

/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!helping-arrays!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
const ll dx[4] = {-1,0,1,0};
const ll dy[4] = {0,-1,0,1};
const ll dxx[] = {1,1,0,-1,-1,-1,0,1};
const ll dyy[] = {0,1,1,1,0,-1,-1,-1};

/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!constants!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
const ll mod=1000000007;
const ll mod2=1000000009;
#define pi 3.1415926535897932
const int N=(int)(1e6+10);
const int FULL_MASK=(1<<10)-1;

/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!Helping-Algos!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/

//---------------Kadanes-algo-------------------//
ll maxSubArraySum(ll a[],ll size){ 
    ll max_so_far=a[0]; 
    ll curr_max=a[0]; 
   for (ll i=1;i<size;i++) { 
        curr_max=max(a[i],curr_max+a[i]); 
        max_so_far=max(max_so_far,curr_max); 
   } 
   return max_so_far; 
} 
//---------------Fendwick-------------------//
int fendwick[N];
void update(int i,int add) {
    while(i>0 && i<N){
        fendwick[i]+=add;
        i+=(i&(-i));
    }
}
 
int sum(int i){
    int s=0;
    while(i>0){
        s+=fendwick[i];
        i=i-(i&(-i));
    }
    return s;
}

/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!helping-functions!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
ll gcd(ll a,ll b){if(!b)return a;return gcd(b,a%b);} 
ll power_mod(ll x,ll y,ll p){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;} 
ll modexpo(ll x,ll n,ll M){if(n==0)return 1;else if(n%2 == 0)return modexpo((x*x)%M,n/2,M);else return(x*modexpo((x*x)%M,(n-1)/2,M))%M;}
ll lcm(ll a, ll b){return (a*b)/gcd(a, b);}
ll sumofdigits(ll n){ll out=0;while(n){out+=(n%10);n/=10;}return out;}
bool isPrime(ll n){if (n <= 1)  
    return false; if (n <= 3)  return true; if (n%2 == 0 || n%3 == 0) return false; 
    for (ll i=5; i*i<=n; i=i+6) if (n%i == 0 || n%(i+2) == 0) return false;return true;} 
// ll power(ll a,ll b){if(b==0)return 1;if(b&1)return a*power(a,b-1);ll res=power(a,b/2);return res*res;}
ll bexpo(ll x,ll n){if(n==0)return 1;else if(n%2==0)return bexpo(x*x,n/2);else return x*bexpo(x*x,(n-1)/2);}
ll log(ll d){return log2(d);}
bool isPower(ll x, ll y){if(x==1) return (y==1); ll pow=1; while(pow<y) pow*=x; return(pow == y);}  
bool isPerfectSquare(long double x){long double sr = sqrt(x);return ((sr - floor(sr)) == 0);}   
bool compare(const pair<ll,ll> &a, const pair<ll,ll> &b) { return (a.second < b.second);} 
ll isPalindrome(string s){ll l=0;ll h=s.size()-1;while(h>l){if(s[l++]!=s[h--])return 0;}return 1;} 
ll setbits(ll n) { if(n==0)return 0; else return 1+setbits(n&(n-1)); } 
ll modInverse(ll A,ll M){return modexpo(A,M-2,M);}
ll suma(ll *a,ll n){ll sum=0;for(ll i=0;i<n;i++)sum+=a[i];return sum;}
void cer(ll x){cout<<x<<"\n";return;}
//------modular inverse by extended euclid-------//
// ll d, x, y;
// void extendedEuclid(ll A, ll B) {
        // if(B==0){
        //     d=A;
        //     x=1;
        //     y=0;
        // }
        // else{
        //     extendedEuclid(B,A%B);
        //     ll temp=x;
        //     x=y;
        //     y=temp-(A/B)*y;
        // }
// }

// ll modInverse2(ll A, ll M){
// extendedEuclid(A,M);
// return (x%M+M)%M;
// }

//---------------matrix exponentiation-------------------//

// matrix mul(matrix a,matrix b){
//   matrix res(n+1,vector<ll>(n+1));
//   f(i,n)f(j,n)f(k,n)res[i][j]=(res[i][j]%mod+((a[i][k]%mod)*(b[k][j]%mod))%mod)%mod;
//    return res;
// }
// matrix pow(matrix A,ll p) {
//     if(p==1) return A;
//     matrix res=pow(A,p/2) ;
//     res=mul(res,res);
//     if(p&1) res=mul(res,A) ;
//     return res;
// }

vector<ll> factorize(ll n) {
    vector<ll> res;
    for (ll i = 2; i * i <= n; ++i) {
        while (n % i == 0) {
            res.push_back(i);
            n /= i;
        }
    }
    if (n != 1) {
        res.push_back(n);
    }
    return res;
}

vector<ll> divisors(ll n){ 
    vector<ll> res;
    for (ll i=1; i<=sqrt(n); i++){ 
        if (n%i == 0){ if (n/i == i){ res.pb(i); } else{ res.pb(n/i); res.pb(i); } } 
    } 
    return res;
}   
vector<ll> primeFactors(ll n){  
    if(n==1) return vector<ll>(1,1);
    bool idx[1]={false};
    vector<ll> res;
    while (n%2 == 0){  
        if(!idx[1]){idx[1]=true;res.pb(2);}
        n = n/2;  
    }  
    for (ll i=3;i*i<=n; i+=2){
        bool once=false;
        while (n%i==0){ if(!once){res.pb(i);once=true;} n=n/i; }  
    }  
    if (n > 2)res.pb(n);
    return res;
}

//----check if a point is in range-----///
bool check(ll x,ll y,ll n,ll m){return(x>=0&&x<n&&y>=0&&y<m);}

//__builtin_ctz(x) --> get power of 2 !!!! 

//---------------BFS-------------------//
vector<vector<ll>> ed;
void bfs(ll s,vector<ll> &d){
    d[s]=0;
    queue<ll>q;
    q.push(s);
    while(!q.empty()){
        ll v=q.front();
        q.pop();
        for(auto to:ed[v]){
            if (d[to]==1e9){
                d[to]=d[v]+1;
                q.push(to);
            }
        }
    }
} 
//---------------DFS-------------------//

// bool vis[N];
// vi adj[N];
// void dfs(ll u){
//     if(vis[u])return;
//     sz++;
//     vis[u]=1;
//     for(auto it:adj[u]){
//         dfs(it);
//     }
// }

// void dfs(ll u){
//     if(vis[u]) return;
//     deg += g[u].size();
//     ver++;
//     vis[u] = 1;
//     for(auto v: g[u])dfs(v);
// }

// const ll NN=100006;
// std::vector<ll> tree[NN];
// double dfs(ll node,ll parent){
//     double sum=0;
//     ll child=0;
//     for(auto i:tree[node]){
//         if(i!=parent){
//             sum+=dfs(i,node);
//             child++;
//         }
//     }
//     if(child){
//         sum/=child;
//         sum+=1;
//     }
//     return sum;
// }

//bs-ready-implementation//
// ll l=1,r=n,ans=0;
// while(l<=r){
//     ll mid=(l+r)>>1;
//     if(ch(mid,n)){
//         ans=mid;
//         r=mid-1;
//     }
//     else{
//         l=mid+1;
//     }
//     
// }
// ce(ans);


/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!extra-data-structures!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/

struct node{
    ll a,b,c,d;
};

/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!logic!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
const ll limit=1e6+5;

void solve(){
   ll a,b,g=1,p,s,i,ans=0;
   in2(n,k);
   queue<pair<ll,ll>>q;
   map<ll,queue<ll>>m;
   bool visited[k]; fill(visited,false);
   f1(i,1,k+1){
      cin>>a>>b;
      if(a==1){
        m[b].push(g);
        q.push({g,b});
        ans++;g++;
      }
      else if(a==2){
         while(!m[b].empty()){
            visited[m[b].front()]=true;
            ans--;
            m[b].pop();
         }
      }
      else{
         while(!q.empty() && q.front().first<=b){
            p = q.front().first;
            s = q.front().second;
            q.pop();
            if(!visited[p]){
               visited[p]=true;
               m[s].pop();
               ans--;
            }
         }
      }
      ce(ans);
   }
}
int main(){
    // speed
    // tc(tt){
        solve();
    // }
}

/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!test-cases!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
/*


*/

 
### Prompt

Generate a cpp solution to the following problem:

Thor is getting used to the Earth. As a gift Loki gave him a smartphone. There are n applications on this phone. Thor is fascinated by this phone. He has only one minor issue: he can't count the number of unread notifications generated by those applications (maybe Loki put a curse on it so he can't).

q events are about to happen (in chronological order). They are of three types:

  1. Application x generates a notification (this new notification is unread). 
  2. Thor reads all notifications generated so far by application x (he may re-read some notifications). 
  3. Thor reads the first t notifications generated by phone applications (notifications generated in first t events of the first type). It's guaranteed that there were at least t events of the first type before this event. Please note that he doesn't read first t unread notifications, he just reads the very first t notifications generated on his phone and he may re-read some of them in this operation. 



Please help Thor and tell him the number of unread notifications after each event. You may assume that initially there are no notifications in the phone.

Input

The first line of input contains two integers n and q (1 ≤ n, q ≤ 300 000) — the number of applications and the number of events to happen.

The next q lines contain the events. The i-th of these lines starts with an integer typei — type of the i-th event. If typei = 1 or typei = 2 then it is followed by an integer xi. Otherwise it is followed by an integer ti (1 ≤ typei ≤ 3, 1 ≤ xi ≤ n, 1 ≤ ti ≤ q).

Output

Print the number of unread notifications after each event.

Examples

Input

3 4
1 3
1 1
1 2
2 3


Output

1
2
3
2


Input

4 6
1 2
1 4
1 2
3 3
1 3
1 3


Output

1
2
3
0
1
2

Note

In the first sample:

  1. Application 3 generates a notification (there is 1 unread notification). 
  2. Application 1 generates a notification (there are 2 unread notifications). 
  3. Application 2 generates a notification (there are 3 unread notifications). 
  4. Thor reads the notification generated by application 3, there are 2 unread notifications left. 



In the second sample test:

  1. Application 2 generates a notification (there is 1 unread notification). 
  2. Application 4 generates a notification (there are 2 unread notifications). 
  3. Application 2 generates a notification (there are 3 unread notifications). 
  4. Thor reads first three notifications and since there are only three of them so far, there will be no unread notification left. 
  5. Application 3 generates a notification (there is 1 unread notification). 
  6. Application 3 generates a notification (there are 2 unread notifications). 

### Response

```cpp
/*
    Nintai-ryoku ga ari, jikan ga kakaru purosesu o shinrai suru 
                                        ~ 死神
*/

#include <bits/stdc++.h>
/*
#include<boost/multiprecision/cpp_int.hpp>
namespace mp=boost::multiprecision;
*/
using namespace std;

/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!shortcuts!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
#define ll                          long long 
// #define ll                          int
#define lo                          mp::cpp_int
#define pb                          push_back
#define pob                         pop_back
#define mk                          make_pair
#define endl                        "\n"                       
#define ce(x)                       cout<<x<<"\n";
#define fill(s,v)                   memset(s,v,sizeof(s))
#define speed                       {ios_base::sync_with_stdio(false); cin.tie(0); }
#define deb(x)                      cout<<#x<<" "<<x<<endl; 
#define ull                         unsigned long long int
#define in(a)                       ll a; cin>>a;
#define in2(a,b)                    ll a,b; cin>>a>>b;
#define in3(a,b,c)                  ll a,b,c; cin>>a>>b>>c;
#define in4(a,b,c,d)                ll a,b,c,d; cin>>a>>b>>c>>d;
#define in5(a,b,c,d,e)              ll a,b,c,d,e; cin>>a>>b>>c>>d>>e;
#define YES                         cout<<"YES"<<endl;
#define Yes                         cout<<"Yes"<<endl;
#define NO                          cout<<"NO"<<endl;
#define No                          cout<<"No"<<endl;
#define yes                         cout<<"yes"<<endl;
#define no                          cout<<"no"<<endl;
#define take(a,n)                   for(ll pp=0;pp<n;pp++) { cin>>a[pp]; }
#define take2(a,n)                  for(ll p=0;p<n;p++) { ll temp;cin>>temp;a.pb(temp); }
#define f(i,n)                      for(ll i=0;i<n;i++)
#define f1(i,a,n)                   for(ll i=a;i<n;i++)
#define show(x)                     for(auto t:x)cout<<t<<" ";
// #define show(a,n) for(ll p=0;p<n;p++) cout<<a[p]<<" ";
#define _                           <<" "<<
#define nl                          cout<<endl;
#define sq(x)                       ((x)*(x))
#define call(v)                     v.begin(),v.end()
#define rall(v)                     v.rbegin(),v.rend()
#define ff                          first
#define ss                          second
#define ld                          long double
#define dekh_lo                     cout<<"dekh_lo"<<endl;
#define de2(x,y)                    cout<<#x<<" = "<<(x) <<' '<< #y<<" = "<<y<<endl;typedef pair<ll,ll> pii;
#define copy(b,a,n)                 for(ll i=0;i<n;i++) b[i]=a[i];
#define lelo(b)                     for(auto &i:b)cin>>i;
#define tc(tt) \
    ll tt;    \
    cin>>tt; \
    for(ll _tt=0;_tt<tt; _tt++) 

/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!data-structures!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
typedef vector<vector<ll>> matrix ;  
typedef pair<ll,ll> pii;
typedef vector<pii> vii;
typedef vector<ll> vi;   

/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!helping-arrays!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
const ll dx[4] = {-1,0,1,0};
const ll dy[4] = {0,-1,0,1};
const ll dxx[] = {1,1,0,-1,-1,-1,0,1};
const ll dyy[] = {0,1,1,1,0,-1,-1,-1};

/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!constants!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
const ll mod=1000000007;
const ll mod2=1000000009;
#define pi 3.1415926535897932
const int N=(int)(1e6+10);
const int FULL_MASK=(1<<10)-1;

/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!Helping-Algos!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/

//---------------Kadanes-algo-------------------//
ll maxSubArraySum(ll a[],ll size){ 
    ll max_so_far=a[0]; 
    ll curr_max=a[0]; 
   for (ll i=1;i<size;i++) { 
        curr_max=max(a[i],curr_max+a[i]); 
        max_so_far=max(max_so_far,curr_max); 
   } 
   return max_so_far; 
} 
//---------------Fendwick-------------------//
int fendwick[N];
void update(int i,int add) {
    while(i>0 && i<N){
        fendwick[i]+=add;
        i+=(i&(-i));
    }
}
 
int sum(int i){
    int s=0;
    while(i>0){
        s+=fendwick[i];
        i=i-(i&(-i));
    }
    return s;
}

/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!helping-functions!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
ll gcd(ll a,ll b){if(!b)return a;return gcd(b,a%b);} 
ll power_mod(ll x,ll y,ll p){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;} 
ll modexpo(ll x,ll n,ll M){if(n==0)return 1;else if(n%2 == 0)return modexpo((x*x)%M,n/2,M);else return(x*modexpo((x*x)%M,(n-1)/2,M))%M;}
ll lcm(ll a, ll b){return (a*b)/gcd(a, b);}
ll sumofdigits(ll n){ll out=0;while(n){out+=(n%10);n/=10;}return out;}
bool isPrime(ll n){if (n <= 1)  
    return false; if (n <= 3)  return true; if (n%2 == 0 || n%3 == 0) return false; 
    for (ll i=5; i*i<=n; i=i+6) if (n%i == 0 || n%(i+2) == 0) return false;return true;} 
// ll power(ll a,ll b){if(b==0)return 1;if(b&1)return a*power(a,b-1);ll res=power(a,b/2);return res*res;}
ll bexpo(ll x,ll n){if(n==0)return 1;else if(n%2==0)return bexpo(x*x,n/2);else return x*bexpo(x*x,(n-1)/2);}
ll log(ll d){return log2(d);}
bool isPower(ll x, ll y){if(x==1) return (y==1); ll pow=1; while(pow<y) pow*=x; return(pow == y);}  
bool isPerfectSquare(long double x){long double sr = sqrt(x);return ((sr - floor(sr)) == 0);}   
bool compare(const pair<ll,ll> &a, const pair<ll,ll> &b) { return (a.second < b.second);} 
ll isPalindrome(string s){ll l=0;ll h=s.size()-1;while(h>l){if(s[l++]!=s[h--])return 0;}return 1;} 
ll setbits(ll n) { if(n==0)return 0; else return 1+setbits(n&(n-1)); } 
ll modInverse(ll A,ll M){return modexpo(A,M-2,M);}
ll suma(ll *a,ll n){ll sum=0;for(ll i=0;i<n;i++)sum+=a[i];return sum;}
void cer(ll x){cout<<x<<"\n";return;}
//------modular inverse by extended euclid-------//
// ll d, x, y;
// void extendedEuclid(ll A, ll B) {
        // if(B==0){
        //     d=A;
        //     x=1;
        //     y=0;
        // }
        // else{
        //     extendedEuclid(B,A%B);
        //     ll temp=x;
        //     x=y;
        //     y=temp-(A/B)*y;
        // }
// }

// ll modInverse2(ll A, ll M){
// extendedEuclid(A,M);
// return (x%M+M)%M;
// }

//---------------matrix exponentiation-------------------//

// matrix mul(matrix a,matrix b){
//   matrix res(n+1,vector<ll>(n+1));
//   f(i,n)f(j,n)f(k,n)res[i][j]=(res[i][j]%mod+((a[i][k]%mod)*(b[k][j]%mod))%mod)%mod;
//    return res;
// }
// matrix pow(matrix A,ll p) {
//     if(p==1) return A;
//     matrix res=pow(A,p/2) ;
//     res=mul(res,res);
//     if(p&1) res=mul(res,A) ;
//     return res;
// }

vector<ll> factorize(ll n) {
    vector<ll> res;
    for (ll i = 2; i * i <= n; ++i) {
        while (n % i == 0) {
            res.push_back(i);
            n /= i;
        }
    }
    if (n != 1) {
        res.push_back(n);
    }
    return res;
}

vector<ll> divisors(ll n){ 
    vector<ll> res;
    for (ll i=1; i<=sqrt(n); i++){ 
        if (n%i == 0){ if (n/i == i){ res.pb(i); } else{ res.pb(n/i); res.pb(i); } } 
    } 
    return res;
}   
vector<ll> primeFactors(ll n){  
    if(n==1) return vector<ll>(1,1);
    bool idx[1]={false};
    vector<ll> res;
    while (n%2 == 0){  
        if(!idx[1]){idx[1]=true;res.pb(2);}
        n = n/2;  
    }  
    for (ll i=3;i*i<=n; i+=2){
        bool once=false;
        while (n%i==0){ if(!once){res.pb(i);once=true;} n=n/i; }  
    }  
    if (n > 2)res.pb(n);
    return res;
}

//----check if a point is in range-----///
bool check(ll x,ll y,ll n,ll m){return(x>=0&&x<n&&y>=0&&y<m);}

//__builtin_ctz(x) --> get power of 2 !!!! 

//---------------BFS-------------------//
vector<vector<ll>> ed;
void bfs(ll s,vector<ll> &d){
    d[s]=0;
    queue<ll>q;
    q.push(s);
    while(!q.empty()){
        ll v=q.front();
        q.pop();
        for(auto to:ed[v]){
            if (d[to]==1e9){
                d[to]=d[v]+1;
                q.push(to);
            }
        }
    }
} 
//---------------DFS-------------------//

// bool vis[N];
// vi adj[N];
// void dfs(ll u){
//     if(vis[u])return;
//     sz++;
//     vis[u]=1;
//     for(auto it:adj[u]){
//         dfs(it);
//     }
// }

// void dfs(ll u){
//     if(vis[u]) return;
//     deg += g[u].size();
//     ver++;
//     vis[u] = 1;
//     for(auto v: g[u])dfs(v);
// }

// const ll NN=100006;
// std::vector<ll> tree[NN];
// double dfs(ll node,ll parent){
//     double sum=0;
//     ll child=0;
//     for(auto i:tree[node]){
//         if(i!=parent){
//             sum+=dfs(i,node);
//             child++;
//         }
//     }
//     if(child){
//         sum/=child;
//         sum+=1;
//     }
//     return sum;
// }

//bs-ready-implementation//
// ll l=1,r=n,ans=0;
// while(l<=r){
//     ll mid=(l+r)>>1;
//     if(ch(mid,n)){
//         ans=mid;
//         r=mid-1;
//     }
//     else{
//         l=mid+1;
//     }
//     
// }
// ce(ans);


/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!extra-data-structures!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/

struct node{
    ll a,b,c,d;
};

/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!logic!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
const ll limit=1e6+5;

void solve(){
   ll a,b,g=1,p,s,i,ans=0;
   in2(n,k);
   queue<pair<ll,ll>>q;
   map<ll,queue<ll>>m;
   bool visited[k]; fill(visited,false);
   f1(i,1,k+1){
      cin>>a>>b;
      if(a==1){
        m[b].push(g);
        q.push({g,b});
        ans++;g++;
      }
      else if(a==2){
         while(!m[b].empty()){
            visited[m[b].front()]=true;
            ans--;
            m[b].pop();
         }
      }
      else{
         while(!q.empty() && q.front().first<=b){
            p = q.front().first;
            s = q.front().second;
            q.pop();
            if(!visited[p]){
               visited[p]=true;
               m[s].pop();
               ans--;
            }
         }
      }
      ce(ans);
   }
}
int main(){
    // speed
    // tc(tt){
        solve();
    // }
}

/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!test-cases!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
/*


*/

 
```