#include<cstdio>
#define inf 1000000001;
int a,b,poz,val;
struct camere
{
int l;
int r;
int c;
};
camere t[200001];
inline int max(int a, int b, int c)
{
int max=a;
if(max<b)
b=max;
if(c>max)
c=max;
return max;
}
void actualizare(int p, int st, int dr)
{
int m;
if(a<=st&&b<=dr)
{
t[p].c=0;
t[p].l=0;
t[p].r=0;
return;
}
m=(st+dr)/2;
if(a<m)
actualizare(2*p,st,m);
if(b>m)
actualizare(2*p+1,m+1,dr);
t[p].l=t[2*p].l;
t[p].r=t[2*p+1].r;
t[p].c=max(t[2*p].c,t[2*p+1].c,t[2*p].r+t[2*p+1].l);
}
void actualizare2(int p, int st, int dr)
{
int m;
if(a<=st&&b<=dr)
{
t[p].c=b-a+1;
t[p].l=b-a+1;
t[p].r=b-a+1;
return;
}
m=(st+dr)/2;
if(a<m)
actualizare2(2*p,st,m);
if(b>m)
actualizare2(2*p+1,m+1,dr);
t[p].l=t[2*p].l;
t[p].r=t[2*p+1].r;
t[p].c=max(t[2*p].c,t[2*p+1].c,t[2*p].r+t[2*p+1].l);
}
int interogare(int p, int st, int dr)
{
int m;
if(a<=st&&b>=dr)
return t[p].c;
m=(st+dr)/2;
if(a<m)
interogare(2*p,st,m);
if(b>m)
interogare(2*p+1,m+1,dr);
return max(t[2*p].c,t[2*p+1].c,t[2*p].r+t[2*p+1].l);
}
int main()
{
freopen("hotel.in","r",stdin);
freopen("hotel.out","w",stdout);
int n,i,j,p,c,lim,k,q;
scanf("%d%d",&n,&p);
t[1].l=t[1].c=t[1].r=n;
lim=1;
k=1<<lim;
for(i=2;i<=2*n-1;++i)
{
if(t[i/2].c%2==1)
{
if(i%2==0)
{
t[i].c=t[i/2].c/2+1;
t[i].l=t[i/2].l/2+1;
t[i].r=t[i/2].r/2+1;
}
}
else
{
t[i].c=t[i/2].c/2;
t[i].l=t[i/2].l/2;
t[i].r=t[i/2].r/2;
}
}
for(i=1;i<=p;++i)
{
scanf("%d",&c);
if(c==1)
{
scanf("%d%d",&a,&b);
actualizare(1,1,n);
}
else
if(c==2)
{
scanf("%d%d",&poz,&val);
actualizare2(1,1,n);
}
else
printf("%d\n",interogare(1,1,n));
}
return 0;
}