#include <cstdio>
#define MAX 65536
#define MaxN 1700005
using namespace std;
int p=0,N,P,V1,V2,Type,sign,X;
char f[MAX];
int max(int a,int b)
{
if(a>b)return a;
else return b;
}
struct Tree
{
int Start,End,All;
}v[MaxN];
void r(int &nr)
{
nr=0;
sign=0;
while(f[p]<'0'||f[p]>'9')
{
if(f[p]=='-')
sign=1;
p++;
if(p==MAX)
fread(f,1,MAX,stdin),p=0;
}
while(f[p]>='0'&&f[p]<='9')
{
nr=nr*10+f[p++]-'0';
if(p==MAX)
fread(f,1,MAX,stdin),p=0;
}
if(sign==1)
nr=-nr;
}
void Answer()
{
printf("%d\n",v[1].All);
}
void Update(int SL,int SR,int L,int R,int pos,int type)
{
if(L>=SL&&R<=SR)
{
v[pos].All=v[pos].Start=v[pos].End=(R-L+1)*type;
return;
}
int mid=(L+R)>>1;
if(v[pos].All==R-L+1)
{
v[2*pos].All=v[2*pos].End=v[2*pos].Start=mid-L+1;
v[2*pos+1].All=v[2*pos+1].End=v[2*pos+1].Start=R-mid;
}
if(v[pos].All==0)
v[2*pos].All=v[2*pos].End=v[2*pos].Start=v[2*pos+1].All=v[2*pos+1].End=v[2*pos+1].Start=0;
if(mid>=SL)
Update(SL,SR,L,mid,2*pos,type);
if(mid<SR)
Update(SL,SR,mid+1,R,2*pos+1,type);
v[pos].End=v[2*pos+1].End+v[2*pos].End*(v[2*pos+1].End==R-mid);
v[pos].Start=v[2*pos].Start+v[2*pos+1].Start*(v[2*pos].Start==mid-L+1);
v[pos].All=max(v[2*pos+1].Start+v[2*pos].End,max(v[2*pos].All,v[2*pos+1].All));
}
int main()
{
freopen("hotel.in","r",stdin);
freopen("hotel.out","w",stdout);
fread(f,1,MAX,stdin);
r(N);r(P);
v[1].All=v[1].End=v[1].Start=N;
for(int i=1;i<=P;i++)
{
r(Type);
if(Type==3)
Answer();
else
{
r(V1);r(V2);
Update(V1,V1+V2-1,1,N,1,Type-1);
}
}
return 0;
}