#include<bits/stdc++.h>
using namespace std;
ifstream in("hotel.in");
ofstream out("hotel.out");
const int N = 1e5;
const int INF = 1e9;
struct Nod
{
int prefix, sufix, bine, lazy = 0;
};
Nod aint[N * 4];
int fs(int nod) { return nod * 2; }
int fd(int nod) { return nod * 2 + 1; }
void update_nod(int nod, int st, int dr)
{
int mij = ( st + dr ) / 2;
aint[nod].bine = max(aint[fs(nod)].sufix + aint[fd(nod)].prefix, max(aint[fs(nod)].bine, aint[fd(nod)].bine));
if ( aint[fs(nod)].prefix == mij - st + 1 )
{
aint[nod].prefix = aint[fs(nod)].prefix + aint[fd(nod)].prefix;
}
else
{
aint[nod].prefix = aint[fs(nod)].prefix;
}
if ( aint[fd(nod)].sufix == dr - mij )
{
aint[nod].sufix = aint[fd(nod)].sufix + aint[fs(nod)].sufix;
}
else
{
aint[nod].sufix = aint[fd(nod)].sufix;
}
}
void update_lazy(int nod, int st, int dr)
{
if ( !aint[nod].lazy )
return;
if ( aint[nod].lazy == 1 )
{
aint[nod] = { 0, 0, 0, 0 };
if ( st != dr )
aint[fs(nod)].lazy = aint[fd(nod)].lazy = 1;
}
if ( aint[nod].lazy == 2 )
{
aint[nod] = { dr - st + 1, dr - st + 1, dr - st + 1, 0 };
if ( st != dr )
aint[fs(nod)].lazy = aint[fd(nod)].lazy = 2;
}
}
void update(int nod, int st, int dr, int qs, int qd, int tip)
{
if ( st > qd || dr < qs )
return;
if ( qs <= st && dr <= qd )
{
aint[nod].lazy = tip;
return;
}
else
{
update_lazy(nod, st, dr);
int mij = ( st + dr ) / 2;
if ( qs <= mij )
{
update(fs(nod), st, mij, qs, qd, tip);
}
if ( mij + 1 <= qd )
{
update(fd(nod), mij + 1, dr, qs, qd, tip);
}
update_lazy(fs(nod), st, mij);
update_lazy(fd(nod), mij + 1, dr);
update_nod(nod, st, dr);
}
}
void rez()
{
int n, p;
in>>n>>p;
aint[1].lazy = 2;
for ( int i = 1 ; i <= p ; i++ )
{
int op;
in>>op;
if ( op == 3 )
{
update_lazy(1, 1, n);
out<<aint[1].bine<<'\n';
continue;
}
int poz, m;
in>>poz>>m;
update(1, 1, n, poz, poz + m - 1, op);
}
}
int main()
{
rez();
return 0;
}