#include<stdio.h>
#include<fstream>
#include<vector>
using namespace std;
//ifstream fin("hotel.in");
//ofstream fout("hotel.out");
int n, m, start, finish, v;
int a[400001], b[400001], c[400001];
void Read();
void Initializare(int nod, int st, int dr );
void Update(int nod, int st, int dr );
int main()
{
Read();
//fin.close();
//fout.close();
return 0;
}
void Read()
{
freopen("hotel.in","r",stdin);
freopen("hotel.out","w",stdout);
scanf("%d %d",&n,&m);
int x, y, t;
Initializare(1, 1, n );
for( int i = 1; i <= m; ++i )
{
scanf("%d",&t);
if( t == 1 )
{
scanf("%d %d",&x,&y);
v = 0;
start = x;
finish = x+y-1;
Update( 1, 1, n );
}
if( t == 2 )
{
scanf("%d %d",&x,&y);
v = 1;
start = x;
finish = x+y-1;
Update(1, 1, n);
}
if( t == 3 )
printf("%d\n", a[1] );
}
}
void Update(int nod, int st, int dr )
{
if( st == dr )
{
a[nod] = v;
b[nod] = v;
c[nod] = v;
return;
}
int mij = (st+dr) >> 1;
int stnod = (nod << 1);
int drnod = stnod + 1;
if( start <= mij )
Update( stnod, st, mij );
if( finish > mij )
Update( drnod, mij+1, dr );
b[nod] = b[stnod];
c[nod] = c[drnod];
if( b[stnod] == (dr - st + 1)- (dr - mij) /*&& arb[2*nod].second.first != 0 */)
b[nod] = b[stnod] + b[drnod];
if( b[drnod] == dr - mij /*&& arb[2*nod+1].second.first != 0 */)
c[nod] = c[stnod] + b[drnod];
a[nod] = max( a[stnod], a[drnod] );
if( a[nod] < b[nod] )
a[nod] = b[nod];
if( a[nod] < c[nod] )
a[nod] = c[nod];
if( a[nod] < c[stnod] + b[drnod] )
a[nod] = c[stnod] + b[drnod];
}
/*
void Update1(int nod, int st, int dr )
{
if( st == dr )
{
arb[nod].first = 1;
arb[nod].second.first = 1;
arb[nod].second.second = 1;
return;
}
int mij = (st + dr) / 2;
if( start <= mij )
Update1( 2*nod, st, mij );
if( finish > mij )
Update1( 2*nod+1, mij+1, dr );
arb[nod].second.first = arb[2*nod].second.first;
arb[nod].second.second = arb[2*nod+1].second.second;
if( arb[2*nod].second.first == (dr- st + 1)- (dr - mij) && arb[2*nod].second.first != 0 )
arb[nod].second.first = arb[2*nod].second.first + arb[2*nod+1].second.first;
if( arb[2*nod+1].second.first == dr - mij && arb[2*nod+1].second.first != 1 )
arb[nod].second.second = arb[2*nod].second.second + arb[2*nod+1].second.second;
arb[nod].first = max( arb[2*nod].first, arb[2*nod+1].first );
if( arb[nod].first < arb[nod].second.first )
arb[nod].first = arb[nod].second.first;
if( arb[nod].first < arb[nod].second.second )
arb[nod].first = arb[nod].second.second;
if( arb[nod].first < arb[2*nod].second.second + arb[2*nod+1].second.first )
arb[nod].first = arb[2*nod].second.second + arb[2*nod+1].second.first;
}
*/
void Initializare( int nod, int st, int dr )
{
if( st == dr )
{
a[nod] = 1;
b[nod] = 1;
c[nod] = 1;
return;
}
int mij = (st+dr)/2;
int stnod = (nod << 1);
int drnod = stnod + 1;
Initializare( stnod, st, mij );
Initializare( drnod, mij+1, dr );
a[nod] = a[stnod] + a[drnod];
b[nod] = b[stnod] + b[drnod];
c[nod] = c[stnod] + c[drnod];
}