#include <iostream>
#include <fstream>
using namespace std;
ifstream in("hotel.in");
ofstream out("hotel.out");
struct nod
{
int max,st,dr;
}a[1000000];
inline int maxim(int a,int b)
{
if(a>b)
return a;
return b;
}
void ocupa(int poz,int left,int right,int p,int q)
{
int k=right-left+1,mid=(right+left)/2;
if(p<=left && right<=q)
{
a[poz].st=0;
a[poz].dr=0;
a[poz].max=0;
return;
}
if(a[poz].st==k && a[poz].dr==k)
{
a[2*poz].st=a[2*poz].max=a[2*poz].dr=mid-left+1;
a[2*poz+1].st=a[2*poz+1].max=a[2*poz+1].dr=right-mid;
}
if(p<=mid)
ocupa(2*poz,left,mid,p,q);
if(mid<q)
ocupa(2*poz+1,mid+1,right,p,q);
if(a[2*poz].st==mid-left+1)
a[poz].st=a[2*poz].st+a[2*poz+1].st;
else
a[poz].st=a[2*poz].st;
if(a[2*poz+1].dr==right-mid)
a[poz].dr=a[2*poz+1].dr+a[2*poz].dr;
else
a[poz].dr=a[2*poz+1].dr;
a[poz].max=maxim(maxim(a[2*poz].max,a[2*poz+1].max),a[2*poz].dr+a[2*poz+1].st);
}
void elibereaza(int poz,int left,int right,int p,int q)
{
int k=right-left+1,mid=(right+left)/2;
if(p<=left && right<=q)
{
a[poz].st=k;
a[poz].dr=k;
a[poz].max=k;
return;
}
if(a[poz].st==0 && a[poz].dr==0)
{
a[2*poz].st=a[2*poz].max=a[2*poz].dr=0;
a[2*poz+1].st=a[2*poz+1].max=a[2*poz+1].dr=0;
}
if(p<=mid)
elibereaza(2*poz,left,mid,p,q);
if(mid<q)
elibereaza(2*poz+1,mid+1,right,p,q);
if(a[2*poz].st==mid-left+1)
a[poz].st=a[2*poz].st+a[2*poz+1].st;
else
a[poz].st=a[2*poz].st;
if(a[2*poz+1].dr==right-mid)
a[poz].dr=a[2*poz+1].dr+a[2*poz].dr;
else
a[poz].dr=a[2*poz+1].dr;
a[poz].max=maxim(maxim(a[2*poz].max,a[2*poz+1].max),a[2*poz].dr+a[2*poz+1].st);
}
int main()
{
int n,p,i,c,poz,m;
in>>n>>p;
a[1].dr=a[1].st=a[1].max=n;
for(i=1;i<=p;++i)
{
in>>c;
if(c==3)
out<<a[1].max<<"\n";
if(c==2)
{
in>>poz>>m;
elibereaza(1,1,n,poz,poz+m-1);
}
if(c==1)
{
in>>poz>>m;
ocupa(1,1,n,poz,poz+m-1);
}
}
return 0;
}