#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define pb push_back
#define all(v) (v).begin() , (v).end()
#define popcnt(x) __builtin_popcount(x)
#define inf 0x3f3f3f3f
#define watch(x) cout << (#x) << " is " << (x) << endl

using namespace __gnu_pbds;
using namespace std;
typedef long long  ll;

template<typename T>
using ordered_set =
tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const int N = 3e5 + 4;
int n , q;
ordered_set<pair<int , int> > s;
set<int> adj[N];

int main(){
#ifndef ONLINE_JUDGE
    freopen("input.txt" , "r" , stdin);
#endif
    cin >> n >> q;

    int cnt = 0;
    for(int i = 0 ; i < q ; ++i){
        int type , t;
        cin >> type >> t;
        if(type == 1){
            s.insert({i , t});
            adj[t].insert(i);
            ++cnt;
        }
        else if(type == 2){
            for(int x : adj[t]){
                auto it = s.lower_bound({x , t});
                s.erase(it);
            }
            cnt -= adj[t].size();
            adj[t].clear();
        }
        else{
            if(s.empty())continue;
            auto it = s.begin();
            while((*it).first <= t){
                s.erase(it);
                --cnt;
                if(s.empty())break;
                it = s.begin();
            }
        }

        cout << cnt << '\n';
    }
}


#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC target("avx")
#include<vector>
#include<iostream>
#define forp(i,a,b)        for(i=a;i<=b;i++)
#define LALIT              ios_base::sync_with_stdio(false);cin.tie(0)

using namespace std;
typedef   int          ll;
typedef pair<ll, ll>           pll;

const int  N = int(300000)+5;

ll  t , n , q  , k ,i, cnt ,sum , x , y , l , r , ans ;

ll a[N] ;

vector<ll> v[N] ;

int main()
{
   LALIT ;
   cin >> n >> q ;
   cnt = l = 1 ;
   forp(i,1,q)
   {
   	 cin >> t >> x ;
   	 if(t==1)
   	 {
   	 	v[x].push_back(cnt) ;
   	 	a[cnt++] = 1 ;
   	 	++sum ;
	  }
	 else if(t==2)
	 {
	 	for(int j=0;j<v[x].size();j++)
	 	{
	 		if(a[v[x][j]])
	 		{
	 			a[v[x][j]]=0;
	 			--sum;
			 }
		 }
	 	v[x].clear() ;
	 }
	 else
	 {
	 	k = x ;
		 while(l<=k)
		 {
		 	if(a[l])
		 	{
		 		a[l] = 0 ;
		 		--sum;
			 }
			 l++;
		 }

	 }
	 cout << sum << "\n" ;
   }

   return 0 ;
}


#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC target("avx")
#include "bits/stdc++.h"

#define wsp                cin >> ws;
#define sp                 setprecision
#define sn(n)              scanf("%lld",&n)
#define cn(n)              cin>>n
#define pr(n)              printf("%lld\n",n)
#define ff                 first
#define ss                 second
#define prn                cout<<endl
#define str(n)             scanf("%s",n)
#define pb                 push_back
#define len(n)             n.length()
#define forp(i,a,b)        for( i=a;i<=b;i++)
#define rep(i,n)           for(ll i=0;i<n;i++)
#define forn(i,a,b)        for(ll i=a;i>=b;i--)
#define ren(i,n)           for(ll i=n-1;i>=0;i--)
#define LALIT              ios_base::sync_with_stdio(false);cin.tie(0)
#define tr(container, it)  for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
#define mem(n,m)           memset(n,m,sizeof(n))
#define mp                 make_pair
#define mod               1000000007

using namespace std;
typedef unsigned long long int ull;
typedef   int          ll;
typedef pair<int, int>         pii;
typedef pair<ll, int>          pli;
typedef pair<double, int>      pdi;
typedef pair<ll, ll>           pll;
typedef pair<double, double>   pdd;

const int  N = int(300000)+5;

ll t , n  , q  , k ,i,j , cnt ,sum , x , y , l , r , ans ;

pll a[N] ;
ll b[N] ;

vector<ll> v[N] ;
int main()
{
   LALIT ;
   cin >> n >> q ;
   forp(i,1,q)
   {
   	 cin >> t >> x ;
   	 if(t==1)
   	 {
   	 	v[x].pb(i) ;
   	 	a[cnt++] = {x,i} ;++b[x];
   	 	++sum ;
		}
	 else if(t==2)
	 {
	 	sum = sum - v[x].size() ;
	 	v[x].clear() ;b[x]=0;
	 }
	 else
	 {
	 	k = x ;
	 	if(k>l){

	 	forp(j,l+1,k)
	 	{
	 	   	x = a[r].ff ;
	 	   	y = a[r].ss ;
	 	   	t = b[x] ;
	 	   	if(t>0)
	 	   	{
	 	   	  if(v[x][0]==y)
				  {
				  v[x].erase(v[x].begin());--sum;--b[x];
			      }
			}
	 	   	r++;
		 }
		 l = k ;
	   }
	 }
	 cout << sum << "\n" ;
   }

   return 0 ;
}


#include "bits/stdc++.h"

#define wsp                cin >> ws;
#define sp                 setprecision
#define sn(n)              scanf("%lld",&n)
#define cn(n)              cin>>n
#define pr(n)              printf("%lld\n",n)
#define ff                 first
#define ss                 second
#define prn                cout<<endl
#define str(n)             scanf("%s",n)
#define pb                 push_back
#define len(n)             n.length()
#define forp(i,a,b)        for(ll i=a;i<=b;i++)
#define rep(i,n)           for(ll i=0;i<n;i++)
#define forn(i,a,b)        for(ll i=a;i>=b;i--)
#define ren(i,n)           for(ll i=n-1;i>=0;i--)
#define LALIT              ios_base::sync_with_stdio(false);cin.tie(0)
#define tr(container, it)  for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
#define mem(n,m)           memset(n,m,sizeof(n))
#define mp                 make_pair
#define mod               1000000007

using namespace std;
typedef unsigned long long int ull;
typedef  long long int          ll;
typedef pair<int, int>         pii;
typedef pair<ll, int>          pli;
typedef pair<double, int>      pdi;
typedef pair<ll, ll>           pll;
typedef pair<double, double>   pdd;

const int  N = int(300000)+5;

ll t , n  , q  , k  , cnt ,sum , x , y , l , r , ans ;

pll a[N] , b[N] ;

vector<ll> v[N] ;
int main()
{
   LALIT ;
   cin >> n >> q ;
   forp(i,1,q)
   {
   	 cin >> t >> x ;
   	 if(t==1)
   	 {
   	 	v[x].pb(i) ;
   	 	a[cnt++] = {x,i} ;
   	 	sum++ ;
		}
	 else if(t==2)
	 {
	 	sum = sum - v[x].size() ;
	 	v[x].clear() ;
	 }
	 else
	 {
	 	k = x ;
	 	forp(j,l+1,k)
	 	{
	 	   	x = a[r].ff ;
	 	   	y = a[r].ss ;
	 	   	t = v[x].size() ;
	 	   	if(t>0)
	 	   	{
	 	   	  if(v[x][0]==y)v[x].erase(v[x].begin()),sum--;
			}
	 	   	r++;
		 }
		 l = max(l,k) ;
	 }
	 cout << sum << "\n" ;
   }

   return 0 ;
}


#include "bits/stdc++.h"

#define wsp                cin >> ws;
#define sp                 setprecision
#define sn(n)              scanf("%lld",&n)
#define cn(n)              cin>>n
#define pr(n)              printf("%lld\n",n)
#define ff                 first
#define ss                 second
#define prn                cout<<endl
#define str(n)             scanf("%s",n)
#define pb                 push_back
#define len(n)             n.length()
#define forp(i,a,b)        for(ll i=a;i<=b;i++)
#define rep(i,n)           for(ll i=0;i<n;i++)
#define forn(i,a,b)        for(ll i=a;i>=b;i--)
#define ren(i,n)           for(ll i=n-1;i>=0;i--)
#define LALIT              ios_base::sync_with_stdio(false);cin.tie(0)
#define tr(container, it)  for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
#define mem(n,m)           memset(n,m,sizeof(n))
#define mp                 make_pair
#define mod               1000000007

using namespace std;
typedef unsigned long long int ull;
typedef  long long int          ll;
typedef pair<int, int>         pii;
typedef pair<ll, int>          pli;
typedef pair<double, int>      pdi;
typedef pair<ll, ll>           pll;
typedef pair<double, double>   pdd;

const int  N = int(100)+5;

ll t , n  , q  , k  , cnt ,sum , x , y , l , r , ans ;

ll a[N] , b[N] ;

map<ll,ll> m ;
int main()
{
   LALIT ;
   cin >> n >> q ;
   while(q--)
   {
   	 cin >> t >> x ;
   	 if(t==1)
   	 {
   	 	m[x]++ ;
   	 	sum++ ;
		}
	 else if(t==2)
	 {
	 	sum = sum - m[x] ;
	 }
	 else
	 {
	 	sum = 0 ;
	 	m.clear() ;
	 }
	 cout << sum << "\n" ;
   }

   return 0 ;
}


#include "bits/stdc++.h"

#define wsp                cin >> ws;
#define sp                 setprecision
#define sn(n)              scanf("%lld",&n)
#define cn(n)              cin>>n
#define pr(n)              printf("%lld\n",n)
#define ff                 first
#define ss                 second
#define prn                cout<<endl
#define str(n)             scanf("%s",n)
#define pb                 push_back
#define len(n)             n.length()
#define forp(i,a,b)        for( i=a;i<=b;i++)
#define rep(i,n)           for(ll i=0;i<n;i++)
#define forn(i,a,b)        for(ll i=a;i>=b;i--)
#define ren(i,n)           for(ll i=n-1;i>=0;i--)
#define LALIT              ios_base::sync_with_stdio(false);cin.tie(0)
#define tr(container, it)  for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
#define mem(n,m)           memset(n,m,sizeof(n))
#define mp                 make_pair
#define mod               1000000007

using namespace std;
typedef unsigned long long int ull;
typedef  long long int          ll;
typedef pair<int, int>         pii;
typedef pair<ll, int>          pli;
typedef pair<double, int>      pdi;
typedef pair<ll, ll>           pll;
typedef pair<double, double>   pdd;

const int  N = int(300000)+5;

ll t , n  , q  , k ,i,j , cnt ,sum , x , y , l , r , ans ;

pll a[N] , b[N] ;

vector<ll> v[N] ;
int main()
{
   LALIT ;
   cin >> n >> q ;
   forp(i,1,q)
   {
   	 cin >> t >> x ;
   	 if(t==1)
   	 {
   	 	v[x].pb(i) ;
   	 	a[cnt++] = {x,i} ;
   	 	sum++ ;
		}
	 else if(t==2)
	 {
	 	sum = sum - v[x].size() ;
	 	v[x].clear() ;
	 }
	 else
	 {
	 	k = x ;
	 	if(k>l){

	 	forp(j,l+1,k)
	 	{
	 	   	x = a[r].ff ;
	 	   	y = a[r].ss ;
	 	   	t = v[x].size() ;
	 	   	if(t>0)
	 	   	{
	 	   	  if(v[x][0]==y)v[x].erase(v[x].begin()),sum--;
			}
	 	   	r++;
		 }
		 l = k ;
	   }
	 }
	 cout << sum << "\n" ;
   }

   return 0 ;
}


#include "bits/stdc++.h"

#define wsp                cin >> ws;
#define sp                 setprecision
#define sn(n)              scanf("%lld",&n)
#define cn(n)              cin>>n
#define pr(n)              printf("%lld\n",n)
#define ff                 first
#define ss                 second
#define prn                cout<<endl
#define str(n)             scanf("%s",n)
#define pb                 push_back
#define len(n)             n.length()
#define forp(i,a,b)        for(ll i=a;i<=b;i++)
#define rep(i,n)           for(ll i=0;i<n;i++)
#define forn(i,a,b)        for(ll i=a;i>=b;i--)
#define ren(i,n)           for(ll i=n-1;i>=0;i--)
#define LALIT              ios_base::sync_with_stdio(false);cin.tie(0)
#define tr(container, it)  for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
#define mem(n,m)           memset(n,m,sizeof(n))
#define mp                 make_pair
#define mod               1000000007

using namespace std;
typedef unsigned long long int ull;
typedef  long long int          ll;
typedef pair<int, int>         pii;
typedef pair<ll, int>          pli;
typedef pair<double, int>      pdi;
typedef pair<ll, ll>           pll;
typedef pair<double, double>   pdd;

const int  N = int(100)+5;

ll t , n  , q  , k  , cnt ,sum , x , y , l , r , ans ;

ll a[N] , b[N] ;

map<ll,ll> m ;
int main()
{
   LALIT ;
   cin >> n >> q ;
   while(q--)
   {
   	 cin >> t >> x ;
   	 if(t==1)
   	 {
   	 	m[x]++ ;
   	 	sum++ ;
		}
	 else if(t==2)
	 {
	 	sum = sum - m[x] ;
	 	m[x] = 0 ;
	 }
	 else
	 {
	 	sum = 0 ;
	 	m.clear() ;
	 }
	 cout << sum << "\n" ;
   }

   return 0 ;
}


#include "bits/stdc++.h"

#define wsp                cin >> ws;
#define sp                 setprecision
#define sn(n)              scanf("%lld",&n)
#define cn(n)              cin>>n
#define pr(n)              printf("%lld\n",n)
#define ff                 first
#define ss                 second
#define prn                cout<<endl
#define str(n)             scanf("%s",n)
#define pb                 push_back
#define len(n)             n.length()
#define forp(i,a,b)        for(ll i=a;i<=b;i++)
#define rep(i,n)           for(ll i=0;i<n;i++)
#define forn(i,a,b)        for(ll i=a;i>=b;i--)
#define ren(i,n)           for(ll i=n-1;i>=0;i--)
#define LALIT              ios_base::sync_with_stdio(false);cin.tie(0)
#define tr(container, it)  for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
#define mem(n,m)           memset(n,m,sizeof(n))
#define mp                 make_pair
#define mod               1000000007

using namespace std;
typedef unsigned long long int ull;
typedef  long long int          ll;
typedef pair<int, int>         pii;
typedef pair<ll, int>          pli;
typedef pair<double, int>      pdi;
typedef pair<ll, ll>           pll;
typedef pair<double, double>   pdd;

const int  N = int(100)+5;

ll t , n  , q  , k  , cnt ,sum , x , y , l , r , ans ;

pll a[N] , b[N] ;

vector<ll> v[N] ;
int main()
{
   LALIT ;
   cin >> n >> q ;
   forp(i,1,q)
   {
   	 cin >> t >> x ;
   	 if(t==1)
   	 {
   	 	v[x].pb(i) ;
   	 	a[cnt++] = {x,i} ;
   	 	sum++ ;
		}
	 else if(t==2)
	 {
	 	sum = sum - v[x].size() ;
	 	v[x].clear() ;
	 }
	 else
	 {
	 	forp(j,l+1,x)
	 	{
	 	   	x = a[r].ff ;
	 	   	y = a[r].ss ;
	 	   	t = v[x].size() ;
	 	   	if(t>0)
	 	   	{
	 	   	  if(v[x][0]==y)v[x].erase(v[x].begin()),sum--;
			}
	 	   	r++;
		 }
		 l = max(l,x) ;
	 }
	 cout << sum << "\n" ;
   }

   return 0 ;
}


#include "bits/stdc++.h"

#define wsp                cin >> ws;
#define sp                 setprecision
#define sn(n)              scanf("%lld",&n)
#define cn(n)              cin>>n
#define pr(n)              printf("%lld\n",n)
#define ff                 first
#define ss                 second
#define prn                cout<<endl
#define str(n)             scanf("%s",n)
#define pb                 push_back
#define len(n)             n.length()
#define forp(i,a,b)        for(ll i=a;i<=b;i++)
#define rep(i,n)           for(ll i=0;i<n;i++)
#define forn(i,a,b)        for(ll i=a;i>=b;i--)
#define ren(i,n)           for(ll i=n-1;i>=0;i--)
#define LALIT              ios_base::sync_with_stdio(false);cin.tie(0)
#define tr(container, it)  for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
#define mem(n,m)           memset(n,m,sizeof(n))
#define mp                 make_pair
#define mod               1000000007

using namespace std;
typedef unsigned long long int ull;
typedef  long long int          ll;
typedef pair<int, int>         pii;
typedef pair<ll, int>          pli;
typedef pair<double, int>      pdi;
typedef pair<ll, ll>           pll;
typedef pair<double, double>   pdd;

const int  N = int(300000)+5;

ll t , n  , q  , k  , cnt ,sum , x , y , l , r , ans ;

pll a[N] , b[N] ;

vector<ll> v[N] ;
int main()
{
   LALIT ;
   cin >> n >> q ;
   forp(i,1,q)
   {
   	 cin >> t >> x ;
   	 if(t==1)
   	 {
   	 	v[x].pb(i) ;
   	 	a[cnt++] = {x,i} ;
   	 	sum++ ;
		}
	 else if(t==2)
	 {
	 	sum = sum - v[x].size() ;
	 	v[x].clear() ;
	 }
	 else
	 {
	 	k = x ;
	 	forp(j,l+1,k)
	 	{
	 	   	x = a[r].ff ;
	 	   	y = a[r].ss ;
	 	   	t = v[x].size() ;
	 	   	if(t>0)
	 	   	{
	 	   	  if(v[x][0]==y)v[x].erase(v[x].begin()),sum--;
			}
	 	   	r++;
		 }
		// cout <<l << " "<<x<<"LAL\n" ;
		 l = max(l,x) ;
	 }
	 cout << sum << "\n" ;
   }

   return 0 ;
}


#include "bits/stdc++.h"

#define wsp                cin >> ws;
#define sp                 setprecision
#define sn(n)              scanf("%lld",&n)
#define cn(n)              cin>>n
#define pr(n)              printf("%lld\n",n)
#define ff                 first
#define ss                 second
#define prn                cout<<endl
#define str(n)             scanf("%s",n)
#define pb                 push_back
#define len(n)             n.length()
#define forp(i,a,b)        for(ll i=a;i<=b;i++)
#define rep(i,n)           for(ll i=0;i<n;i++)
#define forn(i,a,b)        for(ll i=a;i>=b;i--)
#define ren(i,n)           for(ll i=n-1;i>=0;i--)
#define LALIT              ios_base::sync_with_stdio(false);cin.tie(0)
#define tr(container, it)  for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
#define mem(n,m)           memset(n,m,sizeof(n))
#define mp                 make_pair
#define mod               1000000007

using namespace std;
typedef unsigned long long int ull;
typedef  long long int          ll;
typedef pair<int, int>         pii;
typedef pair<ll, int>          pli;
typedef pair<double, int>      pdi;
typedef pair<ll, ll>           pll;
typedef pair<double, double>   pdd;

const int  N = int(100)+5;

ll t , n  , q  , k  , cnt ,sum , x , y , l , r , ans ;

pll a[N] , b[N] ;

vector<ll> v[N] ;
int main()
{
   LALIT ;
   cin >> n >> q ;
   forp(i,1,q)
   {
   	 cin >> t >> x ;
   	 if(t==1)
   	 {
   	 	v[x].pb(i) ;
   	 	a[cnt++] = {x,i} ;
   	 	sum++ ;
		}
	 else if(t==2)
	 {
	 	sum = sum - v[x].size() ;
	 	v[x].clear() ;
	 }
	 else
	 {
	 	k = x ;
	 	forp(j,l+1,k)
	 	{
	 	   	x = a[r].ff ;
	 	   	y = a[r].ss ;
	 	   	t = v[x].size() ;
	 	   	if(t>0)
	 	   	{
	 	   	  if(v[x][0]==y)v[x].erase(v[x].begin()),sum--;
			}
	 	   	r++;
		 }
		// cout <<l << " "<<x<<"LAL\n" ;
		 l = max(l,x) ;
	 }
	 cout << sum << "\n" ;
   }

   return 0 ;
}


#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC target("avx")
#include<vector>
#include<iostream>
#define forp(i,a,b)        for(i=a;i<=b;i++)
#define LALIT              ios_base::sync_with_stdio(false);cin.tie(0)

using namespace std;
typedef   int          ll;
typedef pair<ll, ll>           pll;

const int  N = int(300000)+5;

ll t , n  , q  , k ,i,j , cnt ,sum , x , y , l , r , ans ;

pll a[N] ;
ll b[N] ;

vector<ll> v[N] ;
int main()
{
   LALIT ;
   cin >> n >> q ;
   forp(i,1,q)
   {
   	 cin >> t >> x ;
   	 if(t==1)
   	 {
   	 	v[x].emplace_back(i) ;
   	 	a[cnt++] = {x,i} ;++b[x];
   	 	++sum ;
		}
	 else if(t==2)
	 {
	 	sum = sum - v[x].size() ;
	 	v[x].clear() ;b[x]=0;
	 }
	 else
	 {
	 	k = x ;
	 	if(k>l){

	 	forp(j,l+1,k)
	 	{
	 	   	x = a[r].first ;
	 	   	y = a[r].second ;
	 	   	t = b[x] ;
	 	   	if(t>0)
	 	   	{
	 	   	  if(v[x][0]==y)
				  {
				  v[x].erase(v[x].begin());--sum;--b[x];
			      }
			}
	 	   	r++;
		 }
		 l = k ;
	   }
	 }
	 cout << sum << "\n" ;
   }

   return 0 ;
}


#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC target("avx")
#include<vector>
#include<iostream>
#define forp(i,a,b)        for(i=a;i<=b;i++)
#define LALIT              ios_base::sync_with_stdio(false);cin.tie(0)

using namespace std;
typedef   int          ll;
typedef pair<ll, ll>           pll;

const int  N = int(300000)+5;

ll t , n  , q  , k ,i,j , cnt ,sum , x , y , l , r , ans ;

pll a[N] ;
ll b[N] ,c[N];

vector<ll> v[N] ;
int main()
{
   LALIT ;
   cin >> n >> q ;
   forp(i,1,q)
   {
   	 cin >> t >> x ;
   	 if(t==1)
   	 {
   	 	v[x].emplace_back(i) ;
   	 	a[cnt++] = {x,i} ;++b[x];
   	 	++sum ;
		}
	 else if(t==2)
	 {
	 	sum = sum - v[x].size() ;
	 	v[x].clear() ;b[x]=0;c[x]=0;
	 }
	 else
	 {
	 	k = x ;
	 	if(k>l){

	 	forp(j,l+1,k)
	 	{
	 	   	x = a[r].first ;
	 	   	y = a[r].second ;

	 	   	if(b[x]>c[x])
	 	   	{
	 	   	  if(v[x][c[x]]==y)
				  {
				  ++c[x];--sum;--b[x];
			      }
			}
	 	   	r++;
		 }
		 l = k ;
	   }
	 }
	 cout << sum << "\n" ;
   }

   return 0 ;
}


#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC target("avx")
#include<vector>
#include<iostream>
#define forp(i,a,b)        for(i=a;i<=b;i++)
#define LALIT              ios_base::sync_with_stdio(false);cin.tie(0)

using namespace std;
typedef   int          ll;
typedef pair<ll, ll>           pll;

const int  N = int(300000)+5;

ll  t , n , q  , k ,i, cnt ,sum , x , y , l , r , ans ;

ll a[N] ;

vector<ll> v[N] ;

int main()
{
   LALIT ;
   cin >> n >> q ;
   forp(i,1,q)
   {
   	 cin >> t >> x ;
   	 if(t==1)
   	 {
   	 	v[x].push_back(cnt) ;
   	 	a[cnt++] = 1 ;
   	 	++sum ;
	  }
	 else if(t==2)
	 {
	 	for(int j=0;j<v[x].size();j++)
	 	{
	 		if(a[v[x][j]])
	 		{
	 			a[v[x][j]]=0;
	 			--sum;
			 }
		 }
	 	v[x].clear() ;
	 }
	 else
	 {
	 	k = x ;
		 while(l<=k)
		 {
		 	if(a[l])
		 	{
		 		a[l] = 0 ;
		 		--sum;
			 }
			 l++;
		 }

	 }
	 cout << sum << "\n" ;
   }

   return 0 ;
}


#include "bits/stdc++.h"

#define wsp                cin >> ws;
#define sp                 setprecision
#define sn(n)              scanf("%lld",&n)
#define cn(n)              cin>>n
#define pr(n)              printf("%lld\n",n)
#define ff                 first
#define ss                 second
#define prn                cout<<endl
#define str(n)             scanf("%s",n)
#define pb                 push_back
#define len(n)             n.length()
#define forp(i,a,b)        for(ll i=a;i<=b;i++)
#define rep(i,n)           for(ll i=0;i<n;i++)
#define forn(i,a,b)        for(ll i=a;i>=b;i--)
#define ren(i,n)           for(ll i=n-1;i>=0;i--)
#define LALIT              ios_base::sync_with_stdio(false);cin.tie(0)
#define tr(container, it)  for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
#define mem(n,m)           memset(n,m,sizeof(n))
#define mp                 make_pair
#define mod               1000000007

using namespace std;
typedef unsigned long long int ull;
typedef  long long int          ll;
typedef pair<int, int>         pii;
typedef pair<ll, int>          pli;
typedef pair<double, int>      pdi;
typedef pair<ll, ll>           pll;
typedef pair<double, double>   pdd;

const int  N = int(100)+5;

ll t , n  , q  , k  , cnt ,sum , x , y , l , r , ans ;

pll a[N] , b[N] ;

vector<ll> v[N] ;
int main()
{
   LALIT ;
   cin >> n >> q ;
   forp(i,1,q)
   {
   	 cin >> t >> x ;
   	 if(t==1)
   	 {
   	 	v[x].pb(i) ;
   	 	a[cnt++] = {x,i} ;
   	 	sum++ ;
		}
	 else if(t==2)
	 {
	 	sum = sum - v[x].size() ;
	 	v[x].clear() ;
	 }
	 else
	 {
	 	forp(j,l+1,x)
	 	{
	 	   	x = a[r].ff ;
	 	   	y = a[r].ss ;
	 	   	t = v[x].size() ;
	 	   	if(t>0)
	 	   	{
	 	   	  if(v[x][0]==y)v[x].erase(v[x].begin()),sum--;
			}
	 	   	r++;
		 }
		 l = max(l,t) ;
	 }
	 cout << sum << "\n" ;
   }

   return 0 ;
}


#include<bits/stdc++.h>
using namespace std;
#define int long long int
int32_t main(){
	int n,q;
	cin>>n>>q;
	vector<int>v;
	int count[1000006];
	map<int,int>mp;
	int ans=0;
	int j=0;
	while(q--){
		int a,b;
		cin>>a>>b;
		if(a==1){
			ans++;
			v.push_back(b);
			count[a]++;
		}
		else if(a==2){
			mp[b]+=count[b];
			ans-=count[b];
			count[b]=0;
		}
		else{
			while(j<b){
				if(mp[v[j]]>0){
					j++;
					mp[v[j]]--;
					continue;
				}
				if(count[b]){
					ans--;
					count[b]--;
				}
				j++;
			}
		}
		cout<<ans<<endl;
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define int long long int
int32_t main(){
	int n,q;
	cin>>n>>q;
	vector<int>v;
	int count[1000006];
	map<int,int>mp;
	int ans=0;
	int j=0;
	while(q--){
		int a,b;
		cin>>a>>b;
		if(a==1){
			ans++;
			v.push_back(b);
			count[b]++;
		}
		else if(a==2){
			mp[b]+=count[b];
			ans-=count[b];
			count[b]=0;
		}
		else{
			while(j<=b){
				if(mp[v[j]]>0){
					j++;
					mp[v[j]]--;
					continue;
				}
				if(count[v[j]]){
					ans--;
					count[v[j]]--;
				}
				j++;
			}
		}
		cout<<ans<<endl;
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define int long long int
int32_t main(){
	int n,q;
	cin>>n>>q;
	vector<int>v;
	int count[1000006];
	map<int,int>mp;
	int ans=0;
	int j=0;
	while(q--){
		int a,b;
		cin>>a>>b;
		if(a==1){
			ans++;
			v.push_back(b);
			count[b]++;
		}
		else if(a==2){
			mp[b]+=count[b];
			ans-=count[b];
			count[b]=0;
		}
		else{
			while(j<b){
				if(mp[v[j]]>0){

					mp[v[j]]--;
					j++;
					continue;
				}
				if(count[v[j]]){
					ans--;
					count[v[j]]--;
				}
				j++;
			}
		}
		cout<<ans<<endl;
	}


#include<bits/stdc++.h>
using namespace std;
#define int long long int
int32_t main(){
	int n,q;
	cin>>n>>q;
	vector<int>v;
	int count[1000006];
	map<int,int>mp;
	int ans=0;
	int j=0;
	while(q--){
		int a,b;
		cin>>a>>b;
		if(a==1){
			ans++;
			v.push_back(b);
			count[b]++;
		}
		else if(a==2){
			mp[b]+=count[b];
			ans-=count[b];
			count[b]=0;
		}
		else{
			while(j<b){
				if(mp[v[j]]>0){

					mp[v[j]]--;
					j++;
					continue;
				}
				if(count[v[j]]){
					ans--;
					count[v[j]]--;
				}
				j++;
			}
		}
		cout<<ans<<endl;
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define int long long int
int32_t main(){
	int n,q;
	cin>>n>>q;
	vector<int>v;
	int count[1000006];
	map<int,int>mp;
	int ans=0;
	int j=0;
	while(q--){
		int a,b;
		cin>>a>>b;
		if(a==1){
			ans++;
			v.push_back(b);
			count[b]++;
		}
		else if(a==2){
			mp[b]+=count[b];
			ans-=count[b];
			count[b]=0;
		}
		else{
			while(j<b){
				if(mp[v[j]]>0){
					j++;
					mp[v[j]]--;
					continue;
				}
				if(count[v[j]]){
					ans--;
					count[v[j]]--;
				}
				j++;
			}
		}
		cout<<ans<<endl;
	}
	return 0;
}


#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <climits>
#include <cctype>
#include <cmath>
#include <sstream>
#include <cstdlib>
#include <climits>
#include <ctime>
#include <set>
#include <map>
#include <numeric>
#include <utility>
#include <deque>
#include <queue>
#include <stack>
#include <iomanip>
#include <complex>
#include <list>
#include <bitset>
#include <fstream>
#include <limits>
#include <memory.h>
#include <tgmath.h>
#include <complex>
using namespace std;

typedef complex<int> point;
#define dp(a, b) ((conj(a) * b).real())
#define cp(a, b) ((conj(a) * b).imag())
#define angle(a) (atan2(a.imag(), a.real()))
#define rotate0(a, angle) (a * exp(point(0, angle)))
#define length(a) (hypot(a.imag(), a.real()))
#define rotateAr(a, angle, around) (rotate0(((a) - (around)),(angle)) + around)
#define reflect(a, m) (conj((a)/(m)) * (m))
#define normalize(a) ((a) / length(a));
typedef long long ll;
#define rep(i, start, end) for(int i = start; i < end; ++i)
#define per(i, start, end) for(int i = (int)start-1; i >= end; --i)
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(d, v) memset(d, v, sizeof(d))
#define pii pair<int, int>
const double PI = 3.14159265358979323846;
const double eps = (1e-6);
int dcmp(double x, double y)
{
	// -1 means left is bigger
	return fabs(x - y) <= eps ? 0 : x > y ? -1 : 1;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
#ifndef ONLINE_JUDGE
	freopen("inputE.txt", "r", stdin);
//    freopen("facebook.txt", "w", stdout);
#endif
	int n, q;
	cin >> n >> q;
	vector<int> app(n), action, used(n, -1);
	int sum = 0, st = 0;
	rep(i,0,q)
	{
		int c, x;
		cin >> c >> x;
		--x;
		if (c == 1)
		{
			app[x]++;
			action.push_back(x);
			sum++;
		}
		else if (c == 2)
		{
			used[x] = i;
			sum -= app[x];
			app[x] = 0;
		}
		else
		{
			++x;
			for (int j = st; j < x; ++j)
			{
				if (j > used[action[j]])
				{
					app[action[j]]--;
					sum--;
				}
			}
			st = x;
		}
		cout << sum << '\n';
	}
	return 0;
}


#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <climits>
#include <cctype>
#include <cmath>
#include <sstream>
#include <cstdlib>
#include <climits>
#include <ctime>
#include <set>
#include <map>
#include <numeric>
#include <utility>
#include <deque>
#include <queue>
#include <stack>
#include <iomanip>
#include <complex>
#include <list>
#include <bitset>
#include <fstream>
#include <limits>
#include <memory.h>
#include <tgmath.h>
#include <complex>
using namespace std;

typedef complex<int> point;
#define dp(a, b) ((conj(a) * b).real())
#define cp(a, b) ((conj(a) * b).imag())
#define angle(a) (atan2(a.imag(), a.real()))
#define rotate0(a, angle) (a * exp(point(0, angle)))
#define length(a) (hypot(a.imag(), a.real()))
#define rotateAr(a, angle, around) (rotate0(((a) - (around)),(angle)) + around)
#define reflect(a, m) (conj((a)/(m)) * (m))
#define normalize(a) ((a) / length(a));
typedef long long ll;
#define rep(i, start, end) for(int i = start; i < end; ++i)
#define per(i, start, end) for(int i = (int)start-1; i >= end; --i)
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(d, v) memset(d, v, sizeof(d))
#define pii pair<int, int>
const double PI = 3.14159265358979323846;
const double eps = (1e-6);
int dcmp(double x, double y)
{
	// -1 means left is bigger
	return fabs(x - y) <= eps ? 0 : x > y ? -1 : 1;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
#ifndef ONLINE_JUDGE
	freopen("inputE.txt", "r", stdin);
//    freopen("facebook.txt", "w", stdout);
#endif
	int n, q;
	cin >> n >> q;
	vector<int> app(n), action, used(n);
	int sum = 0, st = 0;
	rep(i,0,q)
	{
		int c, x;
		cin >> c >> x;
		--x;
		if (c == 1)
		{
			app[x]++;
			action.push_back(x);
			sum++;
		}
		else if (c == 2)
		{
			used[x] += app[x];
			sum -= app[x];
			app[x] = 0;
		}
		else
		{
			++x;
			for (int j = st; j < x; ++j)
			{
				if (used[action[j]])
					used[action[j]]--;
				else
				{
					sum--;
					app[action[j]]--;
					used[action[j]]--;
				}
			}
			st = x;
		}
		cout << sum << '\n';
	}
	return 0;
}


#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <climits>
#include <cctype>
#include <cmath>
#include <sstream>
#include <cstdlib>
#include <climits>
#include <ctime>
#include <set>
#include <map>
#include <numeric>
#include <utility>
#include <deque>
#include <queue>
#include <stack>
#include <iomanip>
#include <complex>
#include <list>
#include <bitset>
#include <fstream>
#include <limits>
#include <memory.h>
#include <tgmath.h>
#include <complex>
#include <assert.h>
using namespace std;

typedef complex<int> point;
#define dp(a, b) ((conj(a) * b).real())
#define cp(a, b) ((conj(a) * b).imag())
#define angle(a) (atan2(a.imag(), a.real()))
#define rotate0(a, angle) (a * exp(point(0, angle)))
#define length(a) (hypot(a.imag(), a.real()))
#define rotateAr(a, angle, around) (rotate0(((a) - (around)),(angle)) + around)
#define reflect(a, m) (conj((a)/(m)) * (m))
#define normalize(a) ((a) / length(a));
typedef long long ll;
#define rep(i, start, end) for(int i = start; i < end; ++i)
#define per(i, start, end) for(int i = (int)start-1; i >= end; --i)
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(d, v) memset(d, v, sizeof(d))
#define pii pair<int, int>
const long double PI = 3.14159265358979323846;
const long double eps = (1e-7);
int dcmp(long double x, long double y)
{
	// -1 means left is bigger
	return fabs(x - y) <= eps ? 0 : x > y ? -1 : 1;
}
const int MAX_N = 300000;
vector<int> a[MAX_N];
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("inputA.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
#endif
	int n, q;
	scanf("%d %d", &n, &q);
	vector<int> lastDel(n);
	vector<bool> isDel(q);
	int i = 0, ans = 0, max3 = 0;
	// total complexit is q + 2 * type1 queries count I guess
	while(q--)
	{
		int type, t;
		scanf("%d %d", &type, &t);
		--t;
		if (type == 1)
		{
			a[t].push_back(i);
			++ans;
			++i;
		}
		else if (type == 2)
		{
			for (int j = lastDel[t]; j < sz(a[t]); ++j) // total complexity = typ1 queries
			{
				if (!isDel[a[t][j]])
				{
					isDel[a[t][j]] = 1;
					ans--;
				}
			}
			lastDel[t] = sz(a[t]);
		}
		else if (t >= max3)
		{
			for (int j = max3; j <= t; ++j) // total complexity = type1 queries
			{
				if (!isDel[j])
				{
					ans--;
					isDel[j] = 1;
				}
			}
			max3 = t;
		}
		printf("%d\n", ans);
	}
	return 0;
}


#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <climits>
#include <cctype>
#include <cmath>
#include <sstream>
#include <cstdlib>
#include <climits>
#include <ctime>
#include <set>
#include <map>
#include <numeric>
#include <utility>
#include <deque>
#include <queue>
#include <stack>
#include <iomanip>
#include <complex>
#include <list>
#include <bitset>
#include <fstream>
#include <limits>
#include <memory.h>
#include <tgmath.h>
#include <complex>
using namespace std;

typedef complex<int> point;
#define dp(a, b) ((conj(a) * b).real())
#define cp(a, b) ((conj(a) * b).imag())
#define angle(a) (atan2(a.imag(), a.real()))
#define rotate0(a, angle) (a * exp(point(0, angle)))
#define length(a) (hypot(a.imag(), a.real()))
#define rotateAr(a, angle, around) (rotate0(((a) - (around)),(angle)) + around)
#define reflect(a, m) (conj((a)/(m)) * (m))
#define normalize(a) ((a) / length(a));
typedef long long ll;
#define rep(i, start, end) for(int i = start; i < end; ++i)
#define per(i, start, end) for(int i = (int)start-1; i >= end; --i)
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(d, v) memset(d, v, sizeof(d))
#define pii pair<int, int>
const double PI = 3.14159265358979323846;
const double eps = (1e-6);
int dcmp(double x, double y)
{
	// -1 means left is bigger
	return fabs(x - y) <= eps ? 0 : x > y ? -1 : 1;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
#ifndef ONLINE_JUDGE
	freopen("inputE.txt", "r", stdin);
//    freopen("facebook.txt", "w", stdout);
#endif
	int n, q;
	cin >> n >> q;
	vector<int> app(n), action;
	int sum = 0, st = 0;
	rep(i,0,q)
	{
		int c, x;
		cin >> c >> x;
		--x;
		if (c == 1)
		{
			app[x]++;
			action.push_back(x);
			sum++;
		}
		else if (c == 2)
		{
			sum -= app[x];
			app[x] = 0;
		}
		else
		{
			++x;
			for (int j = st; j < x; ++j)
			{
				sum--;
				app[action[j]]--;
			}
			st = x;
		}
		cout << sum << '\n';
	}
	return 0;
}


#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <climits>
#include <cctype>
#include <cmath>
#include <sstream>
#include <cstdlib>
#include <climits>
#include <ctime>
#include <set>
#include <map>
#include <numeric>
#include <utility>
#include <deque>
#include <queue>
#include <stack>
#include <iomanip>
#include <complex>
#include <list>
#include <bitset>
#include <fstream>
#include <limits>
#include <memory.h>
#include <tgmath.h>
#include <complex>
using namespace std;

typedef complex<int> point;
#define dp(a, b) ((conj(a) * b).real())
#define cp(a, b) ((conj(a) * b).imag())
#define angle(a) (atan2(a.imag(), a.real()))
#define rotate0(a, angle) (a * exp(point(0, angle)))
#define length(a) (hypot(a.imag(), a.real()))
#define rotateAr(a, angle, around) (rotate0(((a) - (around)),(angle)) + around)
#define reflect(a, m) (conj((a)/(m)) * (m))
#define normalize(a) ((a) / length(a));
typedef long long ll;
#define rep(i, start, end) for(int i = start; i < end; ++i)
#define per(i, start, end) for(int i = (int)start-1; i >= end; --i)
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(d, v) memset(d, v, sizeof(d))
#define pii pair<int, int>
const double PI = 3.14159265358979323846;
const double eps = (1e-6);
int dcmp(double x, double y)
{
	// -1 means left is bigger
	return fabs(x - y) <= eps ? 0 : x > y ? -1 : 1;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
#ifndef ONLINE_JUDGE
	freopen("inputE.txt", "r", stdin);
//    freopen("facebook.txt", "w", stdout);
#endif
	int n, q;
	cin >> n >> q;
	vector<int> app(n), action, used(n);
	int sum = 0, st = 0;
	rep(i,0,q)
	{
		int c, x;
		cin >> c >> x;
		--x;
		if (c == 1)
		{
			app[x]++;
			action.push_back(x);
			sum++;
		}
		else if (c == 2)
		{
			used[x] += app[x];
			sum -= app[x];
			app[x] = 0;
		}
		else
		{
			++x;
			for (int j = st; j < x; ++j)
			{
				if (used[action[j]])
					used[action[j]]--;
				else
				{
					sum--;
					app[action[j]]--;
				}
			}
			st = x;
		}
		cout << sum << '\n';
	}
	return 0;
}


#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <climits>
#include <cctype>
#include <cmath>
#include <sstream>
#include <cstdlib>
#include <climits>
#include <ctime>
#include <set>
#include <map>
#include <numeric>
#include <utility>
#include <deque>
#include <queue>
#include <stack>
#include <iomanip>
#include <complex>
#include <list>
#include <bitset>
#include <fstream>
#include <limits>
#include <memory.h>
#include <tgmath.h>
#include <complex>
using namespace std;

typedef complex<int> point;
#define dp(a, b) ((conj(a) * b).real())
#define cp(a, b) ((conj(a) * b).imag())
#define angle(a) (atan2(a.imag(), a.real()))
#define rotate0(a, angle) (a * exp(point(0, angle)))
#define length(a) (hypot(a.imag(), a.real()))
#define rotateAr(a, angle, around) (rotate0(((a) - (around)),(angle)) + around)
#define reflect(a, m) (conj((a)/(m)) * (m))
#define normalize(a) ((a) / length(a));
typedef long long ll;
#define rep(i, start, end) for(int i = start; i < end; ++i)
#define per(i, start, end) for(int i = (int)start-1; i >= end; --i)
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(d, v) memset(d, v, sizeof(d))
#define pii pair<int, int>
const double PI = 3.14159265358979323846;
const double eps = (1e-6);
int dcmp(double x, double y)
{
	// -1 means left is bigger
	return fabs(x - y) <= eps ? 0 : x > y ? -1 : 1;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
#ifndef ONLINE_JUDGE
	freopen("inputE.txt", "r", stdin);
//    freopen("facebook.txt", "w", stdout);
#endif
	int n, q;
	cin >> n >> q;
	vector<int> app(n), action, used(n, -1);
	int sum = 0, st = 0;
	int event = 0;
	rep(i,0,q)
	{
		int c, x;
		cin >> c >> x;
		--x;
		if (c == 1)
		{
			event++;
			app[x]++;
			action.push_back(x);
			sum++;
		}
		else if (c == 2)
		{
			used[x] = event - 1;
			sum -= app[x];
			app[x] = 0;
		}
		else
		{
			++x;
			for (int j = st; j < x; ++j)
			{
				if (j > used[action[j]])
				{
					app[action[j]]--;
					sum--;
				}
			}
			st = x;
		}
		cout << sum << '\n';
	}
	return 0;
}


#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <climits>
#include <cctype>
#include <cmath>
#include <sstream>
#include <cstdlib>
#include <climits>
#include <ctime>
#include <set>
#include <map>
#include <numeric>
#include <utility>
#include <deque>
#include <queue>
#include <stack>
#include <iomanip>
#include <complex>
#include <list>
#include <bitset>
#include <fstream>
#include <limits>
#include <memory.h>
#include <tgmath.h>
#include <complex>
#include <assert.h>
using namespace std;

typedef complex<int> point;
#define dp(a, b) ((conj(a) * b).real())
#define cp(a, b) ((conj(a) * b).imag())
#define angle(a) (atan2(a.imag(), a.real()))
#define rotate0(a, angle) (a * exp(point(0, angle)))
#define length(a) (hypot(a.imag(), a.real()))
#define rotateAr(a, angle, around) (rotate0(((a) - (around)),(angle)) + around)
#define reflect(a, m) (conj((a)/(m)) * (m))
#define normalize(a) ((a) / length(a));
typedef long long ll;
#define rep(i, start, end) for(int i = start; i < end; ++i)
#define per(i, start, end) for(int i = (int)start-1; i >= end; --i)
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(d, v) memset(d, v, sizeof(d))
#define pii pair<int, int>
const long double PI = 3.14159265358979323846;
const long double eps = (1e-7);
int dcmp(long double x, long double y)
{
	// -1 means left is bigger
	return fabs(x - y) <= eps ? 0 : x > y ? -1 : 1;
}
const int MAX_N = 300000;
vector<int> a[MAX_N];
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("inputA.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
#endif
	int n, q;
	cin >> n >> q;
	vector<int> lastDel(n);
	vector<bool> isDel(q);
	int i = 0, ans = 0, max3 = 0;
	// total complexit is q + 2 * type1 queries count I guess
	while(q--)
	{
		int type, t;
		cin >> type >> t;
		--t;
		if (type == 1)
		{
			a[t].push_back(i);
			++ans;
			++i;
		}
		else if (type == 2)
		{
			for (int j = lastDel[t]; j < sz(a[t]); ++j) // total complexity = typ1 queries
			{
				if (!isDel[a[t][j]])
				{
					isDel[a[t][j]] = 1;
					ans--;
				}
			}
			lastDel[t] = sz(a[t]);
		}
		else if (t >= max3)
		{
			for (int j = max3; j <= t; ++j) // total complexity = type1 queries
			{
				if (!isDel[j])
				{
					ans--;
					isDel[j] = 1;
				}
			}
		}
		cout << ans << '\n';
	}
	return 0;
}


#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <climits>
#include <cctype>
#include <cmath>
#include <sstream>
#include <cstdlib>
#include <climits>
#include <ctime>
#include <set>
#include <map>
#include <numeric>
#include <utility>
#include <deque>
#include <queue>
#include <stack>
#include <iomanip>
#include <complex>
#include <list>
#include <bitset>
#include <fstream>
#include <limits>
#include <memory.h>
#include <tgmath.h>
#include <complex>
using namespace std;

typedef complex<int> point;
#define dp(a, b) ((conj(a) * b).real())
#define cp(a, b) ((conj(a) * b).imag())
#define angle(a) (atan2(a.imag(), a.real()))
#define rotate0(a, angle) (a * exp(point(0, angle)))
#define length(a) (hypot(a.imag(), a.real()))
#define rotateAr(a, angle, around) (rotate0(((a) - (around)),(angle)) + around)
#define reflect(a, m) (conj((a)/(m)) * (m))
#define normalize(a) ((a) / length(a));
typedef long long ll;
#define rep(i, start, end) for(int i = start; i < end; ++i)
#define per(i, start, end) for(int i = (int)start-1; i >= end; --i)
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(d, v) memset(d, v, sizeof(d))
#define pii pair<int, int>
const double PI = 3.14159265358979323846;
const double eps = (1e-6);
int dcmp(double x, double y)
{
	// -1 means left is bigger
	return fabs(x - y) <= eps ? 0 : x > y ? -1 : 1;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
#ifndef ONLINE_JUDGE
	freopen("inputE.txt", "r", stdin);
//    freopen("facebook.txt", "w", stdout);
#endif
	int n, q;
	cin >> n >> q;
	vector<int> app(n), action, used(n, -1);
	int sum = 0, st = 0;
	rep(i,0,q)
	{
		int c, x;
		cin >> c >> x;
		--x;
		if (c == 1)
		{
			app[x]++;
			action.push_back(x);
			sum++;
		}
		else if (c == 2)
		{
			used[x] = sz(action) - 1;
			sum -= app[x];
			app[x] = 0;
		}
		else
		{
			++x;
			for (int j = st; j < x; ++j)
			{
				if (j > used[action[j]])
				{
					app[action[j]]--;
					sum--;
				}
			}
			st = x;
		}
		cout << sum << '\n';
	}
	return 0;
}


#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <climits>
#include <cctype>
#include <cmath>
#include <sstream>
#include <cstdlib>
#include <climits>
#include <ctime>
#include <set>
#include <map>
#include <numeric>
#include <utility>
#include <deque>
#include <queue>
#include <stack>
#include <iomanip>
#include <complex>
#include <list>
#include <bitset>
#include <fstream>
#include <limits>
#include <memory.h>
#include <tgmath.h>
#include <complex>
#include <assert.h>
using namespace std;

typedef complex<int> point;
#define dp(a, b) ((conj(a) * b).real())
#define cp(a, b) ((conj(a) * b).imag())
#define angle(a) (atan2(a.imag(), a.real()))
#define rotate0(a, angle) (a * exp(point(0, angle)))
#define length(a) (hypot(a.imag(), a.real()))
#define rotateAr(a, angle, around) (rotate0(((a) - (around)),(angle)) + around)
#define reflect(a, m) (conj((a)/(m)) * (m))
#define normalize(a) ((a) / length(a));
typedef long long ll;
#define rep(i, start, end) for(int i = start; i < end; ++i)
#define per(i, start, end) for(int i = (int)start-1; i >= end; --i)
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(d, v) memset(d, v, sizeof(d))
#define pii pair<int, int>
const long double PI = 3.14159265358979323846;
const long double eps = (1e-7);
int dcmp(long double x, long double y)
{
	// -1 means left is bigger
	return fabs(x - y) <= eps ? 0 : x > y ? -1 : 1;
}
const int MAX_N = 300000;
vector<int> a[MAX_N];
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("inputA.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
#endif
	int n, q;
	scanf("%d %d", &n, &q);
	vector<int> lastDel(n);
	vector<bool> isDel(q);
	int i = 0, ans = 0, max3 = 0;
	// total complexit is q + 2 * type1 queries count I guess
	while(q--)
	{
		int type, t;
		scanf("%d %d", &type, &t);
		--t;
		if (type == 1)
		{
			a[t].push_back(i);
			++ans;
			++i;
		}
		else if (type == 2)
		{
			for (int j = lastDel[t]; j < sz(a[t]); ++j) // total complexity = typ1 queries
			{
				if (!isDel[a[t][j]])
				{
					isDel[a[t][j]] = 1;
					ans--;
				}
			}
			lastDel[t] = sz(a[t]);
		}
		else if (t >= max3)
		{
			for (int j = max3; j <= t; ++j) // total complexity = type1 queries
			{
				if (!isDel[j])
				{
					ans--;
					isDel[j] = 1;
				}
			}
		}
		printf("%d\n", ans);
	}
	return 0;
}


#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <climits>
#include <cctype>
#include <cmath>
#include <sstream>
#include <cstdlib>
#include <climits>
#include <ctime>
#include <set>
#include <map>
#include <numeric>
#include <utility>
#include <deque>
#include <queue>
#include <stack>
#include <iomanip>
#include <complex>
#include <list>
#include <bitset>
#include <fstream>
#include <limits>
#include <memory.h>
#include <tgmath.h>
#include <complex>
#include <assert.h>
using namespace std;

typedef complex<int> point;
#define dp(a, b) ((conj(a) * b).real())
#define cp(a, b) ((conj(a) * b).imag())
#define angle(a) (atan2(a.imag(), a.real()))
#define rotate0(a, angle) (a * exp(point(0, angle)))
#define length(a) (hypot(a.imag(), a.real()))
#define rotateAr(a, angle, around) (rotate0(((a) - (around)),(angle)) + around)
#define reflect(a, m) (conj((a)/(m)) * (m))
#define normalize(a) ((a) / length(a));
typedef long long ll;
#define rep(i, start, end) for(int i = start; i < end; ++i)
#define per(i, start, end) for(int i = (int)start-1; i >= end; --i)
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(d, v) memset(d, v, sizeof(d))
#define pii pair<int, int>
const long double PI = 3.14159265358979323846;
const long double eps = (1e-7);
int dcmp(long double x, long double y)
{
	// -1 means left is bigger
	return fabs(x - y) <= eps ? 0 : x > y ? -1 : 1;
}
const int MAX_N = 300000;
vector<int> a[MAX_N];
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("inputA.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
#endif
	int n, q;
	cin >> n >> q;
	vector<int> lastDel(n);
	vector<bool> isDel(q);
	int i = 0, ans = 0, max3 = 0;
	// total complexit is q + 2 * type1 queries count I guess
	while(q--)
	{
		int type, t;
		cin >> type >> t;
		--t;
		if (type == 1)
		{
			a[t].push_back(i);
			++ans;
			++i;
		}
		else if (type == 2)
		{
			for (int j = lastDel[t]; j < sz(a[t]); ++j) // total complexity = typ1 queries
			{
				if (!isDel[a[t][j]])
				{
					isDel[a[t][j]] = 1;
					ans--;
				}
			}
			lastDel[t] = sz(a[t]);
		}
		else if (t >= max3)
		{
			for (int j = max3; j <= t; ++j) // total complexity = type1 queries
			{
				if (!isDel[j])
				{
					ans--;
					isDel[j] = 1;
				}
			}
			max3 = t;
		}
		cout << ans << '\n';
	}
	return 0;
}


#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <climits>
#include <cctype>
#include <cmath>
#include <sstream>
#include <cstdlib>
#include <climits>
#include <ctime>
#include <set>
#include <map>
#include <numeric>
#include <utility>
#include <deque>
#include <queue>
#include <stack>
#include <iomanip>
#include <complex>
#include <list>
#include <bitset>
#include <fstream>
#include <limits>
#include <memory.h>
#include <tgmath.h>
#include <complex>
using namespace std;

typedef complex<int> point;
#define dp(a, b) ((conj(a) * b).real())
#define cp(a, b) ((conj(a) * b).imag())
#define angle(a) (atan2(a.imag(), a.real()))
#define rotate0(a, angle) (a * exp(point(0, angle)))
#define length(a) (hypot(a.imag(), a.real()))
#define rotateAr(a, angle, around) (rotate0(((a) - (around)),(angle)) + around)
#define reflect(a, m) (conj((a)/(m)) * (m))
#define normalize(a) ((a) / length(a));
typedef long long ll;
#define rep(i, start, end) for(int i = start; i < end; ++i)
#define per(i, start, end) for(int i = (int)start-1; i >= end; --i)
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(d, v) memset(d, v, sizeof(d))
#define pii pair<int, int>
const double PI = 3.14159265358979323846;
const double eps = (1e-6);
int dcmp(double x, double y)
{
	// -1 means left is bigger
	return fabs(x - y) <= eps ? 0 : x > y ? -1 : 1;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
#ifndef ONLINE_JUDGE
	freopen("inputE.txt", "r", stdin);
//    freopen("facebook.txt", "w", stdout);
#endif
	int n, q;
	cin >> n >> q;
	vector<int> app(n), action, used(n, -1);
	int sum = 0, st = 0;
	int event = 0;
	rep(i,0,q)
	{
		int c, x;
		cin >> c >> x;
		--x;
		if (c == 1)
		{
			event++;
			app[x]++;
			action.push_back(x);
			sum++;
		}
		else if (c == 2)
		{
			used[x] = event;
			sum -= app[x];
			app[x] = 0;
		}
		else
		{
			++x;
			for (int j = st; j < x; ++j)
			{
				if (j > used[action[j]])
				{
					app[action[j]]--;
					sum--;
				}
			}
			st = x;
		}
		cout << sum << '\n';
	}
	return 0;
}


#include <iostream>
#include <cstdio>
#include <vector>

using namespace std;

int n,q,ans,del;
vector <int> a;
int g[300000];

int main()
{
    cin>>n>>q;
    while (q--)
    {
        int x,y;
        cin>>x>>y;
        if (x==1)
        {
            a.push_back(y);
            g[y]++;
            cout<<++ans<<endl;
        }
        if (x==2)
        {
            for (int i=del; i<a.size(); i++)
                if (a[i]==y)
                {
                    g[a[i]]--;
                    a[i]=0;
                }

            ans=0;
            for (int i=1; i<=n; i++)
                ans+=g[i];
            cout<<ans<<endl;

        }
        if (x==3)
        {
            if (y>del)
                for (; del<=y; del++)
                    g[a[del]]--;

            ans=0;
            for (int i=1; i<=n; i++)
                ans+=g[i];
            cout<<ans<<endl;
        }
    }
    return 0;
}


#include <iostream>
#include <cstdio>
#include <vector>

using namespace std;

int n,q,ans,del=1;
vector <int> a(1);
int g[300000];

int main()
{
    cin>>n>>q;
    while (q--)
    {
        int x,y;
        cin>>x>>y;
        if (x==1)
        {
            a.push_back(y);
            g[y]++;
            ans++;
        }
        if (x==2)
        {
            if (g[y])
            for (int i=del; i<a.size(); i++)
                if (a[i]==y)
                {
                    g[a[i]]--;
                    a[i]=0;
                    ans--;
                }
        }
        if (x==3)
        {
                for (;del<=y; del++)
                {
                    if (a[del])
                    {
                        g[a[del]]--;
                        ans--;
                    }
                }
        }
        cout<<ans<<endl;
    }
    return 0;
}


#include <iostream>
#include <cstdio>
#include <vector>

using namespace std;

int n,q,ans,del=1;
vector <int> a(1);
int g[300000];

int main()
{
    cin>>n>>q;
    while (q--)
    {
        int x,y;
        cin>>x>>y;
        if (x==1)
        {
            a.push_back(y);
            g[y]++;
            ans++;
        }
        if (x==2)
        {
            if (g[y])
            for (int i=del; i<a.size(); i++)
                if (a[i]==y)
                {
                    g[a[i]]--;
                    a[i]=0;
                    ans--;
                }
        }
        if (x==3)
        {
            if (y>del)
                for (;del<=y; del++)
                {
                    if (g[a[del]])
                    {
                        g[a[del]]--;
                        ans--;
                    }
                }
        }
        cout<<ans<<endl;
    }
    return 0;
}


#include <iostream>
#include <cstdio>
#include <vector>

using namespace std;

int n,q,ans,del;
vector <int> a(1);
int g[300000];

int main()
{
    cin>>n>>q;
    while (q--)
    {
        int x,y;
        cin>>x>>y;
        if (x==1)
        {
            a.push_back(y);
            g[y]++;
            ans++;
        }
        if (x==2)
        {
            if (g[y])
            for (int i=del; i<a.size(); i++)
                if (a[i]==y)
                {
                    g[a[i]]--;
                    a[i]=0;
                    ans--;
                }
        }
        if (x==3)
        {
            if (y>del)
                for (;del<=y; del++)
                {
                    if (g[a[del]])
                    {
                        g[a[del]]--;
                        ans--;
                    }
                }
        }
        cout<<ans<<endl;
    }
    return 0;
}


#include <iostream>
#include <cstdio>
#include <vector>

using namespace std;

int n,q,ans,del=1;
vector <int> a(1);
int g[300000];

int main()
{
    cin>>n>>q;
    while (q--)
    {
        int x,y;
        cin>>x>>y;
        if (x==1)
        {
            a.push_back(y);
            g[y]++;
            ans++;
        }
        if (x==2)
        {
            if (g[y])
            for (int i=del; i<a.size(); i++)
                if (a[i]==y)
                {
                    g[a[i]]--;
                    a[i]=0;
                    ans--;
                }
        }
        if (x==3)
        {
                for (;del<=y; del++)
                {
                    if (g[a[del]])
                    {
                        g[a[del]]--;
                        ans--;
                    }
                }
        }
        cout<<ans<<endl;
    }
    return 0;
}


#include <iostream>
#include <cstdio>
#include <vector>

using namespace std;

int n,q,ans,del=1;
vector <int> a(1);
int g[400000];
int r[400000];

int main()
{
    cin>>n>>q;
    while (q--)
    {
        int x,y;
        cin>>x>>y;
        if (x==1)
        {
            a.push_back(y);
            g[y]++;
            ans++;
        }
        if (x==2)
        {
            ans-=g[y];
            r[y]+=g[y];
            g[y]=0;
        }
        if (x==3)
        {
                for (;del<=y; del++)
                {
                    int c=a[del];
                    if (r[c])
                        r[c]--;
                    else
                    {
                        ans--;
                        g[c]--;
                    }

                }
        }
        cout<<ans<<endl;
    }
    return 0;
}


#include <iostream>
#include <cstdio>
#include <vector>

using namespace std;

int n,q,ans,del=1;
vector <int> a(1);
int g[400000];

int main()
{
    cin>>n>>q;
    while (q--)
    {
        int x,y;
        cin>>x>>y;
        if (x==1)
        {
            a.push_back(y);
            g[y]++;
            ans++;
        }
        if (x==2)
        {
            if (g[y])
            for (int i=del; i<a.size(); i++)
                if (a[i]==y)
                {
                    g[a[i]]--;
                    a[i]=0;
                    ans--;
                }
        }
        if (x==3)
        {
                for (;del<=y; del++)
                {
                    if (a[del])
                    {
                        g[a[del]]--;
                        ans--;
                    }
                }
        }
        cout<<ans<<endl;
    }
    return 0;
}


#include <iostream>
#include <cstdio>
#include <vector>

using namespace std;

int n,q,ans,del;
vector <int> a;
int g[300000];

int main()
{
    cin>>n>>q;
    while (q--)
    {
        int x,y;
        cin>>x>>y;
        if (x==1)
        {
            a.push_back(y);
            g[y]++;
            ans++;
        }
        if (x==2)
        {
            for (int i=del; i<a.size(); i++)
                if (a[i]==y)
                {
                    g[a[i]]--;
                    a[i]=0;
                    ans--;
                }
        }
        if (x==3)
        {
            if (y>del)
                for (;del<=y; del++)
                {
                    if (g[a[del]])
                    {
                        g[a[del]]--;
                        ans--;
                    }
                }
        }
        cout<<ans<<endl;
    }
    return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
using namespace std;
const int num = 1000 * 400 + 7;
int a[num],n,m,ans=0,size=1,Size[num],size1=0,t=1,b[num],d[num];
int main() {
	scanf("%d%d", &n,&m);
	for (int i = 1; i <= n; ++i)a[i] = 0,Size[i]=0;
	for (int i = 1; i <= m; ++i) {
		int x, y;
		scanf("%d%d", &x, &y);
		if (x == 1) {
			ans++;
			d[size] = y; size++;
			a[y]++;
		}
		else if (x == 2) {
			ans -= a[y];
			a[y] = 0;
            Size[y] = size;
		}
		else {

				for (int j = t; j <=y; ++j) {
					if (Size[d[j]] > j)continue;
					Size[d[j]] = j;
					ans--;
					a[d[j]]--;
				}
				if (t < y)t = y;
		}
		printf("%d\n", ans);
	}
	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
using namespace std;
const int num = 1000 * 400 + 7;
int a[num],n,m,ans=0,size=1,t=1,b[num],d[num];
int main() {
	scanf("%d%d", &n,&m);
	for (int i = 1; i <= n; ++i)a[i] = 0;
	for (int i = 1; i <= m; ++i) {
		int x, y;
		scanf("%d%d", &x, &y);
		if (x == 1) {
			ans++;
			d[size] = y; size++;
			a[y]++;
		}
		else if (x == 2) {
			ans -= a[y];
			a[y] = 0;
		}
		else {
			for (int j = t; j <t+y; ++j) {
				if (!a[d[j]])continue;
				ans--;
				a[d[j]]--;
			}
			t += y;
		}
		printf("%d\n", ans);
	}
	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
using namespace std;
const int num = 1000 * 400 + 7;
int a[num],n,m,ans=0,size=1,size1=1,t=1,b[num],d[num];
int main() {
	scanf("%d%d", &n,&m);
	for (int i = 1; i <= n; ++i)a[i] = 0;
	for (int i = 1; i <= m; ++i) {
		int x, y;
		scanf("%d%d", &x, &y);
		if (x == 1) {
			ans++;
			d[size] = y; size++;
			a[y]++;
		}
		else if (x == 2) {
			ans -= a[y]; size1++;
			a[y] = 0;
		}
		else {
			for (int j = t; j <t+y; ++j) {
				if (!a[d[j]])continue;
				if (j<=size1)continue;
				ans--;
				a[d[j]]--;
			}
			t += y;
		}
		printf("%d\n", ans);
	}
	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
using namespace std;
const int num = 1000 * 400 + 7;
int a[num],n,m,ans=0,size=1,t=1,b[num],d[num];
int main() {
	scanf("%d%d", &n,&m);
	for (int i = 1; i <= n; ++i)a[i] = 0;
	for (int i = 1; i <= m; ++i) {
		int x, y;
		scanf("%d%d", &x, &y);
		if (x == 1) {
			ans++;
			d[size] = y; size++;
			a[y]++;
		}
		else if (x == 2) {
			ans -= a[y];
			a[y] = 0;
		}
		else {
			for (int j = t; j <t+y; ++j) {
				ans -= a[d[j]];
				a[d[j]] = 0;
			}
			t += y;
		}
		printf("%d\n", ans);
	}
	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
using namespace std;
const int num = 1000 * 400 + 7;
int a[num],n,m,ans=0,t=1,b[num],d[num];
int main() {
	scanf("%d%d", &n,&m);
	for (int i = 1; i <= n; ++i)a[i] = 0;
	for (int i = 1; i <= m; ++i) {
		int x, y;
		scanf("%d%d", &b[i], &d[i]);
		if (b[i] == 1) {
			ans++;
			a[d[i]]++;
		}
		else if (b[i] == 2) {
			ans -= a[d[i]];
			a[d[i]] = 0;
		}
		else {
			for (int i = t; i <t+d[i]; ++i) {
				ans -= a[d[i]];
				a[d[i]] = 0;
			}
			t += d[i];
		}
		printf("%d\n", ans);
	}
	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
using namespace std;
const int num = 1000 * 400 + 7;
int a[num],n,m,ans=0,size=1,Size[num],size1=0,t=1,b[num],d[num];
int main() {
	scanf("%d%d", &n,&m);
	for (int i = 1; i <= n; ++i)a[i] = 0,Size[i]=0;
	for (int i = 1; i <= m; ++i) {
		int x, y;
		scanf("%d%d", &x, &y);
		if (x == 1) {
			ans++;
			d[size] = y; size++;
			a[y]++;
		}
		else if (x == 2) {
			ans -= a[y]; size1++;
			a[y] = 0; Size[y] = size;
		}
		else {
				for (int j = t; j <=y; ++j) {
					if (!a[d[j]])continue;
					if (Size[d[j]] > j)continue;
					Size[d[j]] = j;
					ans--;
					a[d[j]]--;
				}
				if (t < y)t = y;
		}
		printf("%d\n", ans);
	}
	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
using namespace std;
const int num = 1000 * 400 + 7;
int a[num],n,m,ans=0,size=1,t=1,b[num],d[num];
int main() {
	scanf("%d%d", &n,&m);
	for (int i = 1; i <= n; ++i)a[i] = 0;
	for (int i = 1; i <= m; ++i) {
		int x, y;
		scanf("%d%d", &x, &y);
		if (x == 1) {
			ans++;
			d[size] = y; size++;
			a[y]++;
		}
		else if (x == 2) {
			ans -= a[y];
			a[y] = 0;
		}
		else {
			for (int j = t; j <t+y; ++j) {
		//		if (!a[d[j]])continue;
				ans--;
				a[d[j]]--;
			}
			t += y;
		}
		printf("%d\n", ans);
	}
	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
using namespace std;
const int num = 1000 * 400 + 7;
int a[num],n,m,ans=0,size=1,Size[num],t=1,b[num],d[num];
int main() {
	scanf("%d%d", &n,&m);
	for (int i = 1; i <= n; ++i)a[i] = 0,Size[i]=0;
	for (int i = 1; i <= m; ++i) {
		int x, y;
		scanf("%d%d", &x, &y);
		if (x == 1) {
			ans++;
			d[size] = y; size++;
			a[y]++;
		}
		else if (x == 2) {
			ans -= a[y]; Size[y] = i;
			a[y] = 0;
		}
		else {
			for (int j = t; j <t+y; ++j) {
				if (!a[d[j]])continue;
				if (Size[a[d[j]]] >= j)continue;
				ans--;
				a[d[j]]--;
			}
			t += y;
		}
		printf("%d\n", ans);
	}
	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
using namespace std;
const int num = 1000 * 400 + 7;
int a[num],n,m,ans=0,size=1,size1=1,t=1,b[num],d[num];
int main() {
	scanf("%d%d", &n,&m);
	for (int i = 1; i <= n; ++i)a[i] = 0;
	for (int i = 1; i <= m; ++i) {
		int x, y;
		scanf("%d%d", &x, &y);
		if (x == 1) {
			ans++;
			d[size] = y; size++;
			a[y]++;
		}
		else if (x == 2) {
			ans -= a[y]; size1++;
			a[y] = 0;
		}
		else {
			for (int j = t; j <t+y; ++j) {
				if (!a[d[j]])continue;
				if (j<size1)continue;
				ans--;
				a[d[j]]--;
			}
			t += y;
		}
		printf("%d\n", ans);
	}
	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
using namespace std;
const int num = 1000 * 400 + 7;
int a[num],n,m,ans=0,size=1,size1=0,t=1,b[num],d[num];
int main() {
	scanf("%d%d", &n,&m);
	for (int i = 1; i <= n; ++i)a[i] = 0;
	for (int i = 1; i <= m; ++i) {
		int x, y;
		scanf("%d%d", &x, &y);
		if (x == 1) {
			ans++;
			d[size] = y; size++;
			a[y]++;
		}
		else if (x == 2) {
			ans -= a[y]; size1++;
			a[y] = 0;
		}
		else {
			for (int j = t; j <t+y; ++j) {
				if (!a[d[j]])continue;
				if (j<size1)continue;
				ans--;
				a[d[j]]--;
			}
			t += y;
		}
		printf("%d\n", ans);
	}
	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
using namespace std;
const int num = 1000 * 400 + 7;
int a[num],n,m,ans=0,size=1,Size[num],t=1,b[num],d[num];
int main() {
	scanf("%d%d", &n,&m);
	for (int i = 1; i <= n; ++i)a[i] = 0,Size[i]=0;
	for (int i = 1; i <= m; ++i) {
		int x, y;
		scanf("%d%d", &x, &y);
		if (x == 1) {
			ans++;
			d[size] = y; size++;
			a[y]++;
		}
		else if (x == 2) {
			ans -= a[y]; Size[y] = i;
			a[y] = 0;
		}
		else {
			for (int j = t; j <t+y; ++j) {
				if (!a[d[j]])continue;
				if (Size[a[d[j]]] > j)continue;
				ans--;
				a[d[j]]--;
			}
			t += y;
		}
		printf("%d\n", ans);
	}
	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
using namespace std;
const int num = 1000 * 400 + 7;
int a[num],n,m,ans=0,size=1,Size[num],size1=0,t=1,b[num],d[num];
int main() {
	scanf("%d%d", &n,&m);
	for (int i = 1; i <= n; ++i)a[i] = 0,Size[i]=0;
	for (int i = 1; i <= m; ++i) {
		int x, y;
		scanf("%d%d", &x, &y);
		if (x == 1) {
			ans++;
			d[size] = y; size++;
			a[y]++;
		}
		else if (x == 2) {
			ans -= a[y]; size1++;
			a[y] = 0; Size[y] = size;
		}
		else {
			for (int j = t; j <t+y; ++j) {
				if (!a[d[j]])continue;
				if (Size[d[j]]>j)continue;
				Size[d[j]] = j;
				ans--;
				a[d[j]]--;
			}
			t += y;
		}
		printf("%d\n", ans);
	}
	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
using namespace std;
const int num = 1000 * 400 + 7;
int a[num],n,m,ans=0,size=1,t=1,b[num],d[num];
int main() {
	scanf("%d%d", &n,&m);
	for (int i = 1; i <= n; ++i)a[i] = 0;
	for (int i = 1; i <= m; ++i) {
		int x, y;
		scanf("%d%d", &x, &y);
		if (x == 1) {
			ans++;
			d[size] = y; size++;
			a[d[i]]++;
		}
		else if (x == 2) {
			ans -= a[y];
			a[y] = 0;
		}
		else {
			for (int j = t; j <t+y; ++j) {
				ans -= a[d[j]];
				a[d[j]] = 0;
			}
			t += d[i];
		}
		printf("%d\n", ans);
	}
	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
using namespace std;
const int num = 1000 * 400 + 7;
int a[num],n,m,ans=0,size=1,Size[num],size1=0,t=1,b[num],d[num];
int main() {
	scanf("%d%d", &n,&m);
	for (int i = 1; i <= n; ++i)a[i] = 0,Size[i]=0;
	for (int i = 1; i <= m; ++i) {
		int x, y;
		scanf("%d%d", &x, &y);
		if (x == 1) {
			ans++;
			d[size] = y; size++;
			a[y]++;
		}
		else if (x == 2) {
			ans -= a[y];
			a[y] = 0;
		}
		else {

				for (int j = t; j <=y; ++j) {
					if (!a[d[j]])continue;
					ans--;
					a[d[j]]--;
				}
				if (t < y)t = y;
		}
		printf("%d\n", ans);
	}
	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
using namespace std;
const int num = 1000 * 400 + 7;
int a[num],n,m,ans=0,size=1,Size[num],size1=0,j=1,b[num],d[num];
int main() {
	scanf("%d%d", &n,&m);
	for (int i = 1; i <= n; ++i)a[i] = 0,Size[i]=0;
	for (int i = 1; i <= m; ++i) {
		int x, y;
		scanf("%d%d", &x, &y);
		if (x == 1) {
			ans++;
			d[size] = y; size++;
			a[y]++;
		}
		else if (x == 2) {
			ans -= a[y];
			a[y] = 0;
            Size[y] = size;
		}
		else {

				for (; j <=y; ++j) {
					if (Size[d[j]] <=j ) {
						Size[d[j]] = j;
						ans--;
						a[d[j]]--;
					}
				}
		}
		printf("%d\n", ans);
	}
	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
using namespace std;
const int num = 1000 * 400 + 7;
int a[num],n,m,ans=0,size=1,t=1,b[num],d[num];
int main() {
	scanf("%d%d", &n,&m);
	for (int i = 1; i <= n; ++i)a[i] = 0;
	for (int i = 1; i <= m; ++i) {
		int x, y;
		scanf("%d%d", &x, &y);
		if (x == 1) {
			ans++;
			d[size] = y; size++;
			a[y]++;
		}
		else if (x == 2) {
			ans -= a[y];
			a[y] = 0;
		}
		else {
			for (int j = t; j <t+y; ++j) {
				ans -= a[d[j]];
				a[d[j]] = 0;
			}
			t += d[i];
		}
		printf("%d\n", ans);
	}
	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
using namespace std;
const int num = 1000 * 400 + 7;
int a[num],n,m,ans=0,size=1,Size[num],size1=0,t=1,b[num],d[num];
int main() {
	scanf("%d%d", &n,&m);
	for (int i = 1; i <= n; ++i)a[i] = 0,Size[i]=0;
	for (int i = 1; i <= m; ++i) {
		int x, y;
		scanf("%d%d", &x, &y);
		if (x == 1) {
			ans++;
			d[size] = y; size++;
			a[y]++;
		}
		else if (x == 2) {
			ans -= a[y]; size1++;
			a[y] = 0; Size[y] = size;
		}
		else {
			if (y >= t) {
				for (int j = t; j < t + y; ++j) {
					if (!a[d[j]])continue;
					if (Size[d[j]] > j)continue;
					Size[d[j]] = j;
					ans--;
					a[d[j]]--;
				}
				t += y;
			}
		}
		printf("%d\n", ans);
	}
	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
using namespace std;
const int num = 1000 * 400 + 7;
int a[num],n,m,ans=0,t=1,b[num],d[num];
int main() {
	scanf("%d%d", &n,&m);
	for (int i = 1; i <= n; ++i)a[i] = 0;
	for (int i = 1; i <= m; ++i) {
		int x, y;
		scanf("%d%d", &b[i], &d[i]);
		if (b[i] == 1) {
			ans++;
			a[d[i]]++;
		}
		else if (b[i] == 2) {
			ans -= a[d[i]];
			a[d[i]] = 0;
		}
		else {
			for (int j = t; j <t+d[i]; ++j) {
				ans -= a[d[j]];
				a[d[j]] = 0;
			}
			t += d[i];
		}
		printf("%d\n", ans);
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
vector<int> cnt[300005];
int vis[300005];
int main()
{
    ios::sync_with_stdio(0);
    int n,q,all = 0;
    vector<int> li;
    cin>>n>>q;
    for(int i = 0;i<q;i++)
    {
        int x,t;
        cin>>x>>t;
        if(x == 1)
        {
            all++;
            cnt[t].push_back(i);
            li.push_back(t);
        }
        else if(x == 2)
        {
            for(auto pos : cnt[t])
            {
                if(!vis[pos]) all--,vis[pos] = 1;
            }
            cnt[t].clear();
        }
        else
        {
            for(int i = 0;i<t;i++)
            {
                if(!vis[i]) all--,vis[i] = 1;
            }
        }
        cout<<all<<endl;
    }

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int n, q;
const int N = 3e5+10;
vector<int>a[N];
bool unread[N];
int main()
{
	scanf("%d%d", &n, &q);

		int num = 0;
		int pre = 1;
		int g = 0;
		for (int i = 1; i <= q; ++i)
		{
			int op, x;
			scanf("%d%d", &op, &x);
			if (op == 1)
			{
				++g;
				a[x].push_back(g);
				unread[g] = 1;
				++num;
			}
			else if(op == 2)
			{
				for (auto y : a[x]) if (unread[y])
				{
					unread[y] = 0;
					--num;
				}
				a[x].clear();
			}
			else
			{
				while (pre <= x)
				{
					if (unread[pre])
					{
						unread[pre] = 0;
						--num;
					}
					++pre;
				}
			}
			printf("%d\n", num);
		}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
vector<int> cnt[300005];
int vis[300005];
int main()
{
    int n,q,all = 0;
    vector<int> li;
    scanf("%d%d",&n,&q);
    int x,t,nty = 0;
    while(q--)
    {
        scanf("%d%d",&x,&t);
        if(x == 1)
        {

            cnt[t].push_back(nty);
            nty++;
            all++;
        }
        else if(x == 2)
        {
            for(auto pos : cnt[t])
            {
                if(!vis[pos]) all--,vis[pos] =1;
            }
            cnt[t].clear();
        }
        else
        {
            for(int i = 0;i<min(t,nty);i++)
            {
                if(!vis[i]) all--,vis[i] = 1;
            }
        }
        printf("%d\n",all);
    }

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
vector<int> cnt[300005];
int vis[300005];
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n,q,all = 0;
    vector<int> li;
    cin>>n>>q;
    int x,t;
    while(q--)
    {
        cin>>x>>t;
        if(x == 1)
        {
            li.push_back(t);
            cnt[t].push_back((int)li.size()-1);
            all++;
        }
        else if(x == 2)
        {
            for(auto pos : cnt[t])
            {
                if(!vis[pos]) all--,vis[pos] =1;
            }
            cnt[t].clear();
        }
        else
        {
            for(int i = 0;i<min(t,(int)li.size());i++)
            {
                if(!vis[i]) all--,vis[i] = 1;
            }
        }
        cout<<all<<endl;
    }

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
vector<int> cnt[300005];
int vis[300005];
int main()
{
    ios::sync_with_stdio(0);
    int n,q,all = 0,nty = 0;
    vector<int> li;
    cin>>n>>q;
    for(int i = 0;i<q;i++)
    {
        int x,t;
        cin>>x>>t;
        if(x == 1)
        {
            all++;
            nty++;
            cnt[t].push_back(i);
            //li.push_back(t);
        }
        else if(x == 2)
        {
            for(auto pos : cnt[t])
            {
                if(!vis[pos]) all--,vis[pos] = 1;
            }
            cnt[t].clear();
            vis[i] = -1;
        }
        else
        {
            vis[i] = -1;
            for(int k = 0;k<min(i,t);k++)
            {
                if(!vis[k]) all--,vis[k] = 1;
            }
        }
        cout<<all<<endl;
    }

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
vector<int> cnt[300005];
int vis[300005];
int main()
{
    ios::sync_with_stdio(0);
    int n,q,all = 0;
    vector<int> li;
    cin>>n>>q;
    for(int i = 0;i<q;i++)
    {
        int x,t;
        cin>>x>>t;
        if(x == 1)
        {
            all++;
            cnt[t].push_back(i);
            li.push_back(t);
        }
        else if(x == 2)
        {
            for(auto pos : cnt[t])
            {
                if(!vis[pos]) all--,vis[pos] = 1;
            }
            cnt[t].clear();
        }
        else
        {
            for(int i = 0;i<min((int)li.size(),t);i++)
            {
                if(!vis[i]) all--,vis[i] = 1;
            }
        }
        cout<<all<<endl;
    }

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
vector<int> cnt[300005];
int vis[300005];
int main()
{
    int n,q,all = 0;
    vector<int> li;
    scanf("5d%d",&n,&q);
    int x,t;
    while(q--)
    {
        scanf("%d%d",&x,&t);
        if(x == 1)
        {
            li.push_back(t);
            cnt[t].push_back((int)li.size()-1);
            all++;
        }
        else if(x == 2)
        {
            for(auto pos : cnt[t])
            {
                if(!vis[pos]) all--,vis[pos] =1;
            }
            cnt[t].clear();
        }
        else
        {
            for(int i = 0;i<min(t,(int)li.size());i++)
            {
                if(!vis[i]) all--,vis[i] = 1;
            }
        }
        printf("%d\n",all);
    }

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
vector<int> cnt[300005];
int vis[300005];
int main()
{
    int n,q,all = 0;
    vector<int> li;
    scanf("%d%d",&n,&q);
    int x,t;
    while(q--)
    {
        scanf("%d%d",&x,&t);
        if(x == 1)
        {
            li.push_back(t);
            cnt[t].push_back((int)li.size()-1);
            all++;
        }
        else if(x == 2)
        {
            for(auto pos : cnt[t])
            {
                if(!vis[pos]) all--,vis[pos] =1;
            }
            cnt[t].clear();
        }
        else
        {
            for(int i = 0;i<min(t,(int)li.size());i++)
            {
                if(!vis[i]) all--,vis[i] = 1;
            }
        }
        printf("%d\n",all);
    }

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
vector<int> cnt[300005];
int vis[300005];
int main()
{
    ios::sync_with_stdio(0);
    int n,q,all = 0;
    vector<int> li;
    cin>>n>>q;
    for(int i = 0;i<q;i++)
    {
        int x,t;
        cin>>x>>t;
        if(x == 1)
        {
            all++;
            cnt[t].push_back(i);
            li.push_back(t);
        }
        else if(x == 2)
        {
            for(auto pos : cnt[i])
            {
                vis[pos] = 1;
            }
            all -= cnt[i].size();
            cnt[i].clear();
        }
        else
        {
            for(int i = 0;i<t;i++)
            {
                if(!vis[i]) all--,vis[i] = 1;
            }
        }
        cout<<all<<endl;
    }

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
vector<int> cnt[300005];
int vis[300005];
int main()
{
    ios::sync_with_stdio(0);
    int n,q,all = 0;
    vector<int> li;
    cin>>n>>q;
    int x,t;
    while(q--)
    {
        cin>>x>>t;
        if(x == 1)
        {
            li.push_back(t);
            cnt[t].push_back((int)li.size()-1);
            all++;
        }
        else if(x == 2)
        {
            for(auto pos : cnt[t])
            {
                if(!vis[pos]) all--,vis[pos] =1;
            }
            cnt[t].clear();
        }
        else
        {
            for(int i = 0;i<min(t,(int)li.size());i++)
            {
                if(!vis[i]) all--,vis[i] = 1;
            }
        }
        cout<<all<<endl;
    }

    return 0;
}


#include <bits/stdc++.h>
#define ll long long
#define mp make_pair
#define pb push_back
#define lim 300010
#define s second
#define f first
#define sl(n) scanf("%lld", &n)
using namespace std;
queue < ll > unseen[lim];
    ll arr[lim][2];
int main(){

    ll n,qu,i,j,k,q,x,total = 0,last,go,temp;
    sl(n);sl(qu);

    total = 0; k =0; last = 0;

    for(i=1;i<=qu;i++){
        sl(q);sl(x);
        if(q==1){
            total++;
            arr[k][0] = x; arr[k][1] = 1;
            unseen[x].push(k);
            k++;
            printf("%lld\n",total);
        }
        else if(q==2){
            while(!unseen[x].empty()){
                    total--;
                    temp = unseen[x].front();
                    arr[temp][1] = 0;
                    unseen[x].pop();
            }
            printf("%lld\n",total);
        }
        else{
            go = x-1;
            for(last = last;last<=go;last++){
                total = total - arr[last][1];
               // cout<<arr[last][1];
                if(arr[last][1]==1) unseen[arr[last][0]].pop();
                arr[last][1] = 0;
            }

            printf("%lld\n",total);
        }

    }

return 0;}


#include <bits/stdc++.h>
#define ll long long
#define mp make_pair
#define pb push_back
#define lim 300010
#define s second
#define f first
#define sl(n) scanf("%lld", &n)
using namespace std;
vector <ll> unseen[lim];
    ll arr[lim][2];
int main(){

    ll n,qu,i,j,k,q,x,total = 0,last,go;
    sl(n);sl(qu);

    total = 0; k =0; last = 0;

    for(i=1;i<=qu;i++){
        sl(q);sl(x);
        if(q==1){
            total++;
            arr[k][0] = x; arr[k][1] = 1;
            unseen[x].pb(k);
            k++;
            printf("%lld\n",total);
        }
        else if(q==2){
            total = total - unseen[x].size();
            for(j=0;j<unseen[x].size();j++) arr[unseen[x][j]][1] = 0;
            unseen[x].clear();

            printf("%lld\n",total);
        }
        else{
            go = x-1;
            for(last = last;last<=go;last++){
                total = total - arr[last][1];
               // cout<<arr[last][1];
                if(arr[last][1]==1) unseen[arr[last][0]].erase(unseen[arr[last][0]].begin());
                arr[last][1] = 0;
            }

            printf("%lld\n",total);
        }

    }

return 0;}


#include <bits/stdc++.h>
#define ll long long
#define mp make_pair
#define pb push_back
#define lim 300010
#define s second
#define sl(n) scanf("%lld", &n)
using namespace std;
int main(){

    vector <pair <ll,ll> > data;
    vector < ll > unseen[lim];
    ll n,q,qr,x,one=(ll)1,total = 0,last=0,go =0;
    sl(n); sl(q);
    ll i,j;
    for(i=1;i<=q;i++){
        sl(qr); sl(x);
        if(qr==1) {data.pb(mp(x,one)); unseen[x].pb(i); total++;printf("%lld\n",total);}
        else if(qr==2){
            total = total - unseen[x].size();
            for(j=0;j<unseen[x].size();j++)data[unseen[x][j]].s = 0;
            unseen[x].clear();
            //cout<<total<<endl;
            printf("%lld\n",total);
        }
        else{
            go = x-1 ;
            for(last=last;last<=go && last<data.size();last++){
                total = total - data[last].s;
                //cout<<"-> "<<data[last].s<<endl;
                data[last].s = 0;
            }
            printf("%lld\n",total);

        }
    }

return 0;}


#include <bits/stdc++.h>
#define ll long long
#define mp make_pair
#define pb push_back
#define lim 300010
#define s second
#define f first
#define sl(n) scanf("%lld", &n)
using namespace std;
int main(){

    vector <pair <ll,ll> > data;
    vector < ll > unseen[lim];
    ll n,q,qr,x,one=(ll)1,total = 0,last=0,go =0;
    sl(n); sl(q);
    ll i,j,k=0;
    for(i=0;i<q;i++){
        sl(qr); sl(x);
        if(qr==1) {data.pb(mp(x,one)); unseen[x].pb(k);k++; total++;printf("%lld\n",total);}
        else if(qr==2){
            total = total - unseen[x].size();
            for(j=0;j<unseen[x].size();j++)data[unseen[x][j]].s = 0;
            unseen[x].clear();
            //cout<<total<<endl;
            printf("%lld\n",total);
        }
        else{
            go = x-1 ;
            for(last=last;last<=go && last<data.size();last++){
                total = total - data[last].s;
                //cout<<"-> "<<data[last].s<<endl;
                if(data[last].s == one)
                unseen[data[last].f].erase(unseen[data[last].f].begin());
                data[last].s = 0;

            }
            printf("%lld\n",total);

        }
    }

return 0;}


#include <bits/stdc++.h>
#define ll long long
#define mp make_pair
#define pb push_back
#define lim 300010
#define s second
#define sl(n) scanf("%lld", &n)
using namespace std;
int main(){

    vector <pair <ll,ll> > data;
    vector < ll > unseen[lim];
    ll n,q,qr,x,one=(ll)1,total = 0,last=0,go =0;
    sl(n); sl(q);
    ll i,j;
    for(i=1;i<=q;i++){
        sl(qr); sl(x);
        if(qr==1) {data.pb(mp(x,one)); unseen[x].pb(i); total++;printf("%lld\n",total);}
        else if(qr==2){
            total = total - unseen[x].size();
            for(j=0;j<unseen[x].size();j++)data[unseen[x][j]].s = 0;
            unseen[x].clear();
            //cout<<total<<endl;
            printf("%lld\n",total);
        }
        else{
            go = x-1 ;
            for(last=last;last<=go;last++){
                total = total - data[last].s;
                //cout<<"-> "<<data[last].s<<endl;
                data[last].s = 0;
            }
            printf("%lld\n",total);

        }
    }

return 0;}


#include <bits/stdc++.h>
#define ll long long
#define mp make_pair
#define pb push_back
#define lim 300010
#define s second
#define f first
#define sl(n) scanf("%lld", &n)
using namespace std;
int main(){

    vector <pair <ll,ll> > data;
    vector < ll > unseen[lim];
    ll n,q,qr,x,one=(ll)1,total = 0,last=0,go =0;
    sl(n); sl(q);
    ll i,j;
    for(i=1;i<=q;i++){
        sl(qr); sl(x);
        if(qr==1) {data.pb(mp(x,one)); unseen[x].pb(i); total++;printf("%lld\n",total);}
        else if(qr==2){
            total = total - unseen[x].size();
            for(j=0;j<unseen[x].size();j++)data[unseen[x][j]].s = 0;
            unseen[x].clear();
            //cout<<total<<endl;
            printf("%lld\n",total);
        }
        else{
            go = x-1 ;
            for(last=last;last<=go && last<data.size();last++){
                total = total - data[last].s;
                //cout<<"-> "<<data[last].s<<endl;
                if(data[last].s == one)
                unseen[data[last].f].erase(unseen[data[last].f].begin());
                data[last].s = 0;

            }
            printf("%lld\n",total);

        }
    }

return 0;}


/*
------------____________----------------
--------------CRISTIANO-----------------
SUUUUUUUUUIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
GOOOOOOOOOOOOOOAAAAAAAALLLLLLLLLLLLLLLLL

Author- Shubham Jha
IIIT- ALLAHABAD
*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ffor(i,a,b) for(int i=a;i<b;i++)
#define bfor(i,a,b) for(int i=a-1;i>=b;i--)
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define all(x) x.begin(),x.end()
#define fast  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define endl "\n"
int main()
{
  int n,q,i;
  cin>>n>>q;
  int arr[n+1]={0},last_read[n+1]={0},last_inserted[n+1]={0};
  ffor(i,0,n+1)
    arr[i]=0,last_read[i]=-1,last_inserted[i]=-1;;
  int array[q+1],sum=0,last=0,j,count=0,a,b;
  ffor(i,0,q+1)
    array[i]=-1;
  for(i=1;i<=q;i++)
  {
      scanf("%d %d",&a,&b);
      if(a==1)
      {
        arr[b]++;
        sum++;
        array[count]=b;
        count++;
        last_inserted[b]=count-1;
      }
      else if(a==2)
      {
        sum-=arr[b];
        arr[b]=0;
        last_read[b]=last_inserted[b];
      }
      else
      {
       // cout<<v.size()<<endl;
        for(j=last;j<b;j++)
        {
          int temp=array[j];
          if(j>last_read[temp])
          {
            arr[temp]--;
            sum--;
            last_read[temp]=j;
          }
        }
        last=b;
      }
      printf("%d\n",sum);
  }
}


/*
------------____________----------------
--------------CRISTIANO-----------------
SUUUUUUUUUIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
GOOOOOOOOOOOOOOAAAAAAAALLLLLLLLLLLLLLLLL

Author- Shubham Jha
IIIT- ALLAHABAD
*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ffor(i,a,b) for(int i=a;i<b;i++)
#define bfor(i,a,b) for(int i=a-1;i>=b;i--)
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define all(x) x.begin(),x.end()
#define fast  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define endl "\n"
int main()
{
  int n,q;
  cin>>n>>q;
  ll arr[n+1]={0},last_read[n+1]={0},last_inserted[n+1]={0};
  ffor(i,0,n+1)
    arr[i]=0,last_read[i]=-1,last_inserted[i]=-1;;
  int sum=0,last=0,j;
  vector<int>v;
  ffor(i,1,q+1)
  {
      int a,b;
      scanf("%d %d",&a,&b);
      if(a==1)
      {
        arr[b]++;
        sum++;
        v.pb(b);
        last_inserted[b]=v.size()-1;
      }
      else if(a==2)
      {
        sum-=arr[b];
        arr[b]=0;
        last_read[b]=last_inserted[b];
      }
      else
      {
       // cout<<v.size()<<endl;
        for(j=last;j<b;j++)
        {
          int temp=v[j];
          if(j>last_read[temp])
          {
            arr[temp]--;
            sum--;
            last_read[temp]=j;
          }
        }
        last=b;
      }
      printf("%d\n",sum);
  }
}


/*
------------____________----------------
--------------CRISTIANO-----------------
SUUUUUUUUUIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
GOOOOOOOOOOOOOOAAAAAAAALLLLLLLLLLLLLLLLL

Author- Shubham Jha
IIIT- ALLAHABAD
*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ffor(i,a,b) for(int i=a;i<b;i++)
#define bfor(i,a,b) for(int i=a-1;i>=b;i--)
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define all(x) x.begin(),x.end()
#define fast  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define endl "\n"
int main()
{
  int n,q;
  cin>>n>>q;
  ll arr[n+1]={0},last_read[n+1]={0},last_inserted[n+1]={0};
  ffor(i,0,n+1)
    arr[i]=0,last_read[i]=-1,last_inserted[i]=-1;;
  ll sum=0,last=0,j;
  vector<int>v;
  ffor(i,1,q+1)
  {
      int a,b;
      cin>>a>>b;
      if(a==1)
      {
        arr[b]++;
        sum++;
        v.pb(b);
        last_inserted[b]=v.size()-1;
        cout<<sum<<endl;
      }
      else if(a==2)
      {
        sum-=arr[b];
        arr[b]=0;
        last_read[b]=last_inserted[b];
        cout<<sum<<endl;
      }
      else
      {
       // cout<<v.size()<<endl;
        for(j=last;j<b;j++)
        {
          int temp=v[j];
          if(j>last_read[temp])
          {
            arr[temp]--;
            sum--;
            last_read[temp]=j;
          }
        }
        last=b;
        cout<<max(last,sum)<<endl;
      }
  }
}


/*
------------____________----------------
--------------CRISTIANO-----------------
SUUUUUUUUUIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
GOOOOOOOOOOOOOOAAAAAAAALLLLLLLLLLLLLLLLL

Author- Shubham Jha
IIIT- ALLAHABAD
*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ffor(i,a,b) for(int i=a;i<b;i++)
#define bfor(i,a,b) for(int i=a-1;i>=b;i--)
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define all(x) x.begin(),x.end()
#define fast  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define endl "\n"
int main()
{
  int n,q;
  cin>>n>>q;
  ll arr[n+1]={0},last_read[n+1]={0},last_inserted[n+1]={0};
  ffor(i,0,n+1)
    arr[i]=0,last_read[i]=-1,last_inserted[i]=-1;;
  ll sum=0,last=0,j;
  vector<int>v;
  ffor(i,1,q+1)
  {
      int a,b;
      cin>>a>>b;
      if(a==1)
      {
        arr[b]++;
        sum++;
        v.pb(b);
        last_inserted[b]=v.size()-1;
        cout<<sum<<endl;
      }
      else if(a==2)
      {
        sum-=arr[b];
        arr[b]=0;
        last_read[b]=last_inserted[b];
        cout<<sum<<endl;
      }
      else
      {
       // cout<<v.size()<<endl;
        for(j=last;j<b;j++)
        {
          int temp=v[j];
          if(j>last_read[temp])
          {
            arr[temp]--;
            sum--;
            last_read[temp]=j;
          }
        }
        last=max(last,b);
        cout<<sum<<endl;
      }
  }
}


/*
------------____________----------------
--------------CRISTIANO-----------------
SUUUUUUUUUIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
GOOOOOOOOOOOOOOAAAAAAAALLLLLLLLLLLLLLLLL

Author- Shubham Jha
IIIT- ALLAHABAD
*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ffor(i,a,b) for(int i=a;i<b;i++)
#define bfor(i,a,b) for(int i=a-1;i>=b;i--)
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define all(x) x.begin(),x.end()
#define fast  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define endl "\n"
int main()
{
  int n,q;
  cin>>n>>q;
  int arr[n+1]={0},last_read[n+1]={0},last_inserted[n+1]={0};
  ffor(i,0,n+1)
    arr[i]=0,last_read[i]=-1,last_inserted[i]=-1;;
  int sum=0,last=0,j,count=0;
  vector<int>v;
  ffor(i,1,q+1)
  {
      int a,b;
      scanf("%d %d",&a,&b);
      if(a==1)
      {
        arr[b]++;
        sum++;
        v.pb(b);
        count++;
        last_inserted[b]=count-1;
      }
      else if(a==2)
      {
        sum-=arr[b];
        arr[b]=0;
        last_read[b]=last_inserted[b];
      }
      else
      {
       // cout<<v.size()<<endl;
        for(j=last;j<b;j++)
        {
          int temp=v[j];
          if(j>last_read[temp])
          {
            arr[temp]--;
            sum--;
            last_read[temp]=j;
          }
        }
        last=b;
      }
      printf("%d\n",sum);
  }
}


/*
------------____________----------------
--------------CRISTIANO-----------------
SUUUUUUUUUIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
GOOOOOOOOOOOOOOAAAAAAAALLLLLLLLLLLLLLLLL

Author- Shubham Jha
IIIT- ALLAHABAD
*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ffor(i,a,b) for(int i=a;i<b;i++)
#define bfor(i,a,b) for(int i=a-1;i>=b;i--)
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define all(x) x.begin(),x.end()
#define fast  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define endl "\n"
int main()
{
  int n,q;
  cin>>n>>q;
  int arr[n+1]={0},last_read[n+1]={0},last_inserted[n+1]={0};
  ffor(i,0,n+1)
    arr[i]=0,last_read[i]=-1,last_inserted[i]=-1;;
  int sum=0,last=0,j;
  vector<int>v;
  ffor(i,1,q+1)
  {
      int a,b;
      cin>>a>>b;
      if(a==1)
      {
        arr[b]++;
        sum++;
        v.pb(b);
        last_inserted[b]=v.size()-1;
        cout<<sum<<endl;
      }
      else if(a==2)
      {
        sum-=arr[b];
        arr[b]=0;
        last_read[b]=last_inserted[b];
        cout<<sum<<endl;
      }
      else
      {
       // cout<<v.size()<<endl;
        for(j=last;j<b;j++)
        {
          int temp=v[j];
          if(j>last_read[temp])
          {
            arr[temp]--;
            sum--;
            last_read[temp]=j;
          }
        }
        last=max(last,b);
        cout<<sum<<endl;
      }
  }
}


/*
------------____________----------------
--------------CRISTIANO-----------------
SUUUUUUUUUIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
GOOOOOOOOOOOOOOAAAAAAAALLLLLLLLLLLLLLLLL

Author- Shubham Jha
IIIT- ALLAHABAD
*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ffor(i,a,b) for(int i=a;i<b;i++)
#define bfor(i,a,b) for(int i=a-1;i>=b;i--)
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define all(x) x.begin(),x.end()
#define fast  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define endl "\n"
int main()
{
  int n,q;
  cin>>n>>q;
  ll arr[n+1]={0},last_read[n+1]={0},last_inserted[n+1]={0};
  ffor(i,0,n+1)
    arr[i]=0,last_read[i]=-1,last_inserted[i]=-1;;
  int sum=0,last=0,j,count=0;
  vector<int>v;
  ffor(i,1,q+1)
  {
      int a,b;
      scanf("%d %d",&a,&b);
      if(a==1)
      {
        arr[b]++;
        sum++;
        v.pb(b);
        count++;
        last_inserted[b]=count-1;
      }
      else if(a==2)
      {
        sum-=arr[b];
        arr[b]=0;
        last_read[b]=last_inserted[b];
      }
      else
      {
       // cout<<v.size()<<endl;
        for(j=last;j<b;j++)
        {
          int temp=v[j];
          if(j>last_read[temp])
          {
            arr[temp]--;
            sum--;
            last_read[temp]=j;
          }
        }
        last=b;
      }
      printf("%d\n",sum);
  }
}


/*
------------____________----------------
--------------CRISTIANO-----------------
SUUUUUUUUUIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
GOOOOOOOOOOOOOOAAAAAAAALLLLLLLLLLLLLLLLL

Author- Shubham Jha
IIIT- ALLAHABAD
*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ffor(i,a,b) for(int i=a;i<b;i++)
#define bfor(i,a,b) for(int i=a-1;i>=b;i--)
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define all(x) x.begin(),x.end()
#define fast  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define endl "\n"
int main()
{
  int n,q,i;
  cin>>n>>q;
  int arr[n+1]={0},last_read[n+1]={0},last_inserted[n+1]={0};
  ffor(i,0,n+1)
    arr[i]=0,last_read[i]=-1,last_inserted[i]=-1;;
  int array[q+1],sum=0,last=0,j,count=0,a,b;
  ffor(i,0,q+1)
    array[i]=-1;
  for(i=1;i<=q;i++)
  {
      scanf("%d %d",&a,&b);
      if(a==1)
      {
        arr[b]++;
        sum++;
        array[count]=b;
        count++;
        last_inserted[b]=count-1;
      }
      else if(a==2)
      {
        sum-=arr[b];
        arr[b]=0;
        last_read[b]=last_inserted[b];
      }
      else
      {
       // cout<<v.size()<<endl;
        for(j=last;j<b;j++)
        {
          int temp=array[j];
          if(j>last_read[temp])
          {
            arr[temp]--;
            sum--;
            last_read[temp]=j;
          }
        }
        last=max(last,b);
      }
      printf("%d\n",sum);
  }
}


/*
------------____________----------------
--------------CRISTIANO-----------------
SUUUUUUUUUIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
GOOOOOOOOOOOOOOAAAAAAAALLLLLLLLLLLLLLLLL

Author- Shubham Jha
IIIT- ALLAHABAD
*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ffor(i,a,b) for(int i=a;i<b;i++)
#define bfor(i,a,b) for(int i=a-1;i>=b;i--)
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define all(x) x.begin(),x.end()
#define fast  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define endl "\n"
int main()
{
  int n,q;
  cin>>n>>q;
  ll arr[n+1]={0},last_read[n+1]={0};
  ffor(i,0,n+1)
    arr[i]=0,last_read[i]=-1;
  ll sum=0,last=0,j;
  vector<int>v;
  ffor(i,1,q+1)
  {
      int a,b;
      cin>>a>>b;
      if(a==1)
      {
        arr[b]++;
        sum++;
        v.pb(b);
        cout<<sum<<endl;
      }
      else if(a==2)
      {
        sum-=arr[b];
        arr[b]=0;
        cout<<sum<<endl;
      }
      else
      {
       // cout<<v.size()<<endl;
        for(j=last;j<b;j++)
        {
          int temp=v[j];
          if(j>last_read[temp])
          {
            arr[temp]--;
            sum--;
            last_read[temp]=j;
          }
        }
        last=b;
        cout<<sum<<endl;
      }
  }
}


/*
------------____________----------------
--------------CRISTIANO-----------------
SUUUUUUUUUIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
GOOOOOOOOOOOOOOAAAAAAAALLLLLLLLLLLLLLLLL

Author- Shubham Jha
IIIT- ALLAHABAD
*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ffor(i,a,b) for(int i=a;i<b;i++)
#define bfor(i,a,b) for(int i=a-1;i>=b;i--)
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define all(x) x.begin(),x.end()
#define fast  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define endl "\n"
int main()
{
  int n,q;
  cin>>n>>q;
  ll arr[n+1]={0},last_read[n+1]={0},last_inserted[n+1]={0};
  ffor(i,0,n+1)
    arr[i]=0,last_read[i]=-1,last_inserted[i]=-1;;
  ll sum=0,last=0,j;
  vector<int>v;
  ffor(i,1,q+1)
  {
      int a,b;
      cin>>a>>b;
      if(a==1)
      {
        arr[b]++;
        sum++;
        v.pb(b);
        last_inserted[b]=v.size()-1;
        cout<<sum<<endl;
      }
      else if(a==2)
      {
        sum-=arr[b];
        arr[b]=0;
        last_read[b]=last_inserted[b];
        cout<<sum<<endl;
      }
      else
      {
       // cout<<v.size()<<endl;
        for(j=last;j<b;j++)
        {
          int temp=v[j];
          if(j>last_read[temp])
          {
            arr[temp]--;
            sum--;
            last_read[temp]=j;
          }
        }
        last=b;
        cout<<sum<<endl;
      }
  }
}


/*
------------____________----------------
--------------CRISTIANO-----------------
SUUUUUUUUUIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
GOOOOOOOOOOOOOOAAAAAAAALLLLLLLLLLLLLLLLL

Author- Shubham Jha
IIIT- ALLAHABAD
*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ffor(i,a,b) for(int i=a;i<b;i++)
#define bfor(i,a,b) for(int i=a-1;i>=b;i--)
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define all(x) x.begin(),x.end()
#define fast  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define endl "\n"
int main()
{
  int n,q;
  cin>>n>>q;
  ll arr[n+1]={0};
  ll sum=0,last=0,j;
  vector<int>v;
  ffor(i,1,q+1)
  {
      int a,b;
      cin>>a>>b;
      if(a==1)
      {
        arr[b]++;
        sum++;
        v.pb(b);
        cout<<sum<<endl;
      }
      else if(a==2)
      {
        sum-=arr[b];
        arr[b]=0;
        cout<<sum<<endl;
      }
      else
      {
       // cout<<v.size()<<endl;
        for(j=last;j<b;j++)
        {
          int temp=v[j];
          if(arr[temp]>0)
          {
            arr[temp]--;
            sum--;
          }
        }
        last=b;
        cout<<sum<<endl;
      }
  }
}


#include<stdio.h>
#include<vector>
#include<algorithm>
#include<queue>
#include <string>
#include<bits/stdc++.h>
using namespace std;
typedef long long  ll;
typedef pair<ll, ll>pii;
//typedef bitset<19> mask;
//int x4[4]={1,0,0,-1};
//int y4[4]={0,1,-1,0};
int n,q,t,x,ans,c,m,b[400000];
vector<pair<int,int>>v;
vector<int >a[400000];

int main()
{
//freopen("hotel.in","r",stdin);
//freopen("math.in","w",stdout);

cin>>n>>q;
for(int i=1;i<=q;i++)
{
    scanf("%d%d",&t,&x);
    if(t==1)
    {
        ans++;
        m++;
        a[x].push_back(m);
        v.push_back({x,m});
        printf("%d\n",ans);
    }
    else if(t==2)
    {
        ans-=a[x].size()-b[x];
        b[x]+=a[x].size()-b[x];
        printf("%d\n",ans);
    }
    else
    {
        for(int j=c;j<x;j++)
        {
            if(a[v[j].first].size()>0&&a[v[j].first][b[v[j].first]]==v[j].second)
            {
                ans--;
                b[v[j].first]++;
            }

        }
        c=x;

        printf("%d\n",ans);

    }
}

return 0;
}