#include <bits/stdc++.h>
using namespace std;
ifstream in("hotel.in");
ofstream out("hotel.out");
const int lim=1e5+4;
struct node
{
int st;
int dr;
int med;
int len;
}tree[4*lim];
int lazy[4*lim];
node comb(node x,node y)
{
node z;
z.st=x.st;
if(x.len==x.st)
z.st+=y.st;
z.dr=y.dr;
if(y.len==y.dr)
z.dr+=x.dr;
z.med=max({z.st,z.dr,x.med,y.med,x.dr+y.st});
z.len=x.len+y.len;
return z;
}
void build(int nod,int l,int r)
{
if(l==r)
{
tree[nod].st=1;
tree[nod].dr=1;
tree[nod].med=1;
tree[nod].len=1;
return ;
}
int mij=(l+r)>>1;
build(2*nod,l,mij);
build(2*nod+1,mij+1,r);
tree[nod]=comb(tree[2*nod],tree[2*nod+1]);
}
void update_full(int nod,int l,int r,int a,int b)
{
if(l!=r)
{
lazy[2*nod]+=lazy[nod],
lazy[2*nod+1]+=lazy[nod];
if(lazy[2*nod]==1)
tree[2*nod].st=tree[2*nod].len,
tree[2*nod].dr=tree[2*nod].len,
tree[2*nod].med=tree[2*nod].len;
else if(lazy[2*nod]==-1)
tree[2*nod].st=0,
tree[2*nod].dr=0,
tree[2*nod].med=0;
if(lazy[2*nod+1]==1)
tree[2*nod+1].st=tree[2*nod+1].len,
tree[2*nod+1].dr=tree[2*nod+1].len,
tree[2*nod+1].med=tree[2*nod+1].len;
else if(lazy[2*nod+1]==-1)
tree[2*nod+1].st=0,
tree[2*nod+1].dr=0,
tree[2*nod+1].med=0;
}
lazy[nod]=0;
if(a<=l and r<=b)
{
tree[nod].st=0;
tree[nod].dr=0;
tree[nod].med=0;
if(l!=r)
{
lazy[2*nod]--,
lazy[2*nod+1]--;
if(lazy[2*nod]==1)
tree[2*nod].st=tree[2*nod].len,
tree[2*nod].dr=tree[2*nod].len,
tree[2*nod].med=tree[2*nod].len;
else if(lazy[2*nod]==-1)
tree[2*nod].st=0,
tree[2*nod].dr=0,
tree[2*nod].med=0;
if(lazy[2*nod+1]==1)
tree[2*nod+1].st=tree[2*nod+1].len,
tree[2*nod+1].dr=tree[2*nod+1].len,
tree[2*nod+1].med=tree[2*nod+1].len;
else if(lazy[2*nod+1]==-1)
tree[2*nod+1].st=0,
tree[2*nod+1].dr=0,
tree[2*nod+1].med=0;
}
return ;
}
int mij=(l+r)>>1;
if(a<=mij) update_full(2*nod,l,mij,a,b);
if(b>mij) update_full(2*nod+1,mij+1,r,a,b);
tree[nod]=comb(tree[2*nod],tree[2*nod+1]);
}
void update_gol(int nod,int l,int r,int a,int b)
{
if(l!=r)
{
lazy[2*nod]+=lazy[nod],
lazy[2*nod+1]+=lazy[nod];
if(lazy[2*nod]==1)
tree[2*nod].st=tree[2*nod].len,
tree[2*nod].dr=tree[2*nod].len,
tree[2*nod].med=tree[2*nod].len;
else if(lazy[2*nod]==-1)
tree[2*nod].st=0,
tree[2*nod].dr=0,
tree[2*nod].med=0;
if(lazy[2*nod+1]==1)
tree[2*nod+1].st=tree[2*nod+1].len,
tree[2*nod+1].dr=tree[2*nod+1].len,
tree[2*nod+1].med=tree[2*nod+1].len;
else if(lazy[2*nod+1]==-1)
tree[2*nod+1].st=0,
tree[2*nod+1].dr=0,
tree[2*nod+1].med=0;
}
lazy[nod]=0;
if(a<=l and r<=b)
{
tree[nod].st=tree[nod].len;
tree[nod].dr=tree[nod].len;
tree[nod].med=tree[nod].len;
if(l!=r)
{
lazy[2*nod]++,
lazy[2*nod+1]++;
if(lazy[2*nod]==1)
tree[2*nod].st=tree[2*nod].len,
tree[2*nod].dr=tree[2*nod].len,
tree[2*nod].med=tree[2*nod].len;
else if(lazy[2*nod]==-1)
tree[2*nod].st=0,
tree[2*nod].dr=0,
tree[2*nod].med=0;
if(lazy[2*nod+1]==1)
tree[2*nod+1].st=tree[2*nod+1].len,
tree[2*nod+1].dr=tree[2*nod+1].len,
tree[2*nod+1].med=tree[2*nod+1].len;
else if(lazy[2*nod+1]==-1)
tree[2*nod+1].st=0,
tree[2*nod+1].dr=0,
tree[2*nod+1].med=0;
}
return ;
}
int mij=(l+r)>>1;
if(a<=mij) update_gol(2*nod,l,mij,a,b);
if(b>mij) update_gol(2*nod+1,mij+1,r,a,b);
tree[nod]=comb(tree[2*nod],tree[2*nod+1]);
}
node query(int nod,int l,int r,int a,int b)
{
if(lazy[nod]==1)
tree[nod].st=tree[nod].len,
tree[nod].dr=tree[nod].len,
tree[nod].med=tree[nod].len;
else if(lazy[nod]==-1)
tree[nod].st=0,
tree[nod].dr=0,
tree[nod].med=0;
if(l!=r)
lazy[2*nod]+=lazy[nod],
lazy[2*nod+1]+=lazy[nod];
lazy[nod]=0;
if(a<=l and r<=b)
return tree[nod];
int mij=(l+r)>>1;
if(a<=mij and b>mij)
return comb(query(2*nod,l,mij,a,b),
query(2*nod+1,mij+1,r,a,b));
if(a<=mij)
return query(2*nod,l,mij,a,b);
return query(2*nod+1,mij+1,r,a,b);
}
int n,m,t,x,y;
int main()
{
in>>n>>m;
build(1,1,n);
while(m--)
{
in>>t;
if(t==1)
{
in>>x>>y;
update_full(1,1,n,x,x+y-1);
}
else if(t==2)
{
in>>x>>y;
update_gol(1,1,n,x,x+y-1);
}
else out<<query(1,1,n,1,n).med<<'\n';
//cout<<tree[1].med<<' ';
//cout<<tree[2].med<<' ';
//cout<<tree[3].med<<'\n';
}
return 0;
}