#include <bits/stdc++.h>
#define int long long
#define dim 100009
using namespace std;
ifstream fin ("hotel.in");
ofstream fout("hotel.out");
struct el
{
int maxi,pre,suf;
}aint[dim*4];
int n,lazy[dim*4];
void init (int nod,int st,int dr)
{
aint[nod]={dr-st+1,dr-st+1,dr-st+1};
if (st!=dr)
{
int mij=(st+dr)/2;
init(2*nod,st,mij);
init(2*nod+1,mij+1,dr);
}
}
void uneste (int x,int y,int z,int st,int dr)
{
aint[z].pre=aint[x].pre,aint[z].suf=aint[y].suf,aint[z].maxi=max(aint[x].maxi,aint[y].maxi);
int mij=(dr+st)>>1;
if (aint[x].pre==mij-st+1)
aint[z].pre+=aint[y].pre;
if (aint[y].suf==dr-mij)
aint[z].suf+=aint[x].suf;
aint[z].maxi=max(aint[z].maxi,aint[x].suf+aint[y].pre);
}
void propaga (int nod,int st,int dr)
{
if (lazy[nod]==1)
{
aint[nod]={0,0,0};
if (st!=dr)
{
lazy[2*nod]=lazy[nod];
lazy[2*nod+1]=lazy[nod];
}
lazy[nod]=0;
}
else if (lazy[nod]==2)
{
aint[nod]={dr-st+1,dr-st+1,dr-st+1};
if (st!=dr)
{
lazy[2*nod]=lazy[nod];
lazy[2*nod+1]=lazy[nod];
}
lazy[nod]=0;
}
}
void update (int nod,int st,int dr,int l,int r,int val)
{
if (st==l && dr==r)
{
lazy[nod]=val;
propaga (nod,st,dr);
}
else
{
int mij=(st+dr)>>1;
propaga (nod,st,dr);
propaga (2*nod,st,mij);
propaga (2*nod+1,mij+1,dr);
if (r<=mij)
update (2*nod,st,mij,l,r,val);
else if (mij+1<=l)
update (2*nod+1,mij+1,dr,l,r,val);
else
{
update(2*nod,st,mij,l,mij,val);
update(2*nod+1,mij+1,dr,mij+1,r,val);
}
uneste (2*nod,2*nod+1,nod,st,dr);
}
}
void update (int x,int y,int val)
{
update(1,1,n,x,y,val);
}
int32_t main()
{
int tip,q,x,y;
fin>>n>>q;
init(1,1,n);
while (q--)
{
fin>>tip;
if (tip==3)
fout<<aint[1].maxi<<'\n';
else{
fin>>x>>y;
y=x+y-1;
update(x,y,tip);
}
}
return 0;
}