#include <cstdio>
#include <cctype>
#define MAXBUF (1<<20)
#define MAXN 100000
FILE*fi,*fout;
char buf[MAXBUF];
int pos=MAXBUF;
inline char nextch(){
if(pos==MAXBUF){
fread(buf,1,MAXBUF,fi);
pos=0;
}
return buf[pos++];
}
inline int getnr(){
char a=nextch();
char sign=1;
if(a=='-')
sign=-1;
while(isdigit(a)==0)
a=nextch();
int nr=0;
while(isdigit(a)==1){
nr=nr*10+a-'0';
a=nextch();
}
return nr*sign;
}
inline int getmax(int a,int b){
if(a>b) return a;
return b;
}
struct Aint{
int max_lenght;
int first_lenght;
int last_lenght;
};
Aint A[4*MAXN+1];
char lazy[4*MAXN+1];
void update(int nod,int left,int right,int l,int r,char free){
int max1,max2,first1,first2,last1,last2;
if(left<right&&lazy[nod]>-1){
lazy[2*nod]=lazy[nod];
lazy[2*nod+1]=lazy[nod];
}
if(l<=left&&right<=r){
if(left<right){
lazy[2*nod]=free;
lazy[2*nod+1]=free;
}
lazy[nod]=-1;
if(free==1){
A[nod].max_lenght=right-left+1;
A[nod].first_lenght=right-left+1;
A[nod].last_lenght=right-left+1;
}
else{
A[nod].max_lenght=0;
A[nod].first_lenght=0;
A[nod].last_lenght=0;
}
}
else{
int med=(left+right)/2;
lazy[nod]=-1;
if(l<=med)
update(2*nod,left,med,l,r,free);
if(med<r)
update(2*nod+1,med+1,right,l,r,free);
if(lazy[2*nod]==1||lazy[2*nod]==-1){
max1=A[2*nod].max_lenght;
first1=A[2*nod].first_lenght;
last1=A[2*nod].last_lenght;
}
else{
max1=0;
first1=0;
last1=0;
}
if(lazy[2*nod+1]==1||lazy[2*nod+1]==-1){
max2=A[2*nod+1].max_lenght;
first2=A[2*nod+1].first_lenght;
last2=A[2*nod+1].last_lenght;
}
else{
max2=0;
first2=0;
last2=0;
}
A[nod].max_lenght=getmax(last1+first2,getmax(max1,max2));
if(first1==med-left+1)
A[nod].first_lenght=first1+first2;
else
A[nod].first_lenght=first1;
if(last2==right-med)
A[nod].last_lenght=last2+last1;
else
A[nod].last_lenght=last2;
}
}
int main(){
int i,n,l,x,q,t;
fi=fopen("hotel.in" ,"r");
fout=fopen("hotel.out" ,"w");
n=getnr();
for(i=1;i<=4*n;i++)
lazy[i]=-1;
for(i=1;i<=n;i++)
update(1,1,n,i,i,1);
q=getnr();
while(q>0){
q--;
t=getnr();
if(t==1){
l=getnr();
x=getnr();
update(1,1,n,l,l+x-1,0);
}
if(t==2){
l=getnr();
x=getnr();
update(1,1,n,l,l+x-1,1);
}
if(t==3)
fprintf(fout,"%d\n" ,A[1].max_lenght);
}
fclose(fi);
fclose(fout);
return 0;
}