#include<cstdio>
using namespace std;
#define MAX_N 100000
int s[MAX_N*3+2];
int st[MAX_N*3+2];
int dr[MAX_N*3+2];
int N,P;
inline int max(int a, int b) { return (a>b)? (a) : (b); }
void update(int n, int l, int r, int i, int j, int ok) // a[i..j] = ok
{
if(i<=l && r<=j)
{
if(ok == 1) st[n] = dr[n] = s[n] = 0;
else st[n] = dr[n] = s[n] = r-l+1;
return;
}
int m = (l+r) >> 1, fs = n<<1, fd = n<<1|1;
if(s[n] == r-l+1)
{
st[fs] = dr[fs] = s[fs] = m-l+1;
st[fd] = dr[fd] = s[fd] = r-m;
}
if(!s[n]) st[fs] = dr[fs] = s[fs] = dr[fd] = st[fd] = s[fd] = 0;
if(i<=m) update(fs,l,m,i,j,ok);
if(j>m) update(fd,m+1,r,i,j,ok);
st[n] = st[fs];
dr[n] = dr[fd];
if(st[fs] == m-l+1) st[n] = st[fs] + st[fd];
if(dr[fd] == r-m) dr[n] = dr[fd] + dr[fs];
s[n] = max(s[fs], s[fd]);
s[n] = max(s[n], dr[fs]+st[fd]);
}
void build(int n, int l, int r)
{
if(r == l) { st[n] = dr[n] = s[n] = 1; return ; }
int m = (l+r)>>1, fs=n<<1, fd=n<<1|1;
build(fs,l,m);
build(fd,m+1,r);
s[n] = st[n] = dr[n] = r-l+1;
}
int main()
{
freopen("hotel.in","r",stdin);
freopen("hotel.out","w",stdout);
scanf("%d%d",&N,&P);
int c,i,m;
build(1,1,N);
while(P--)
{
scanf("%d",&c);
if(c == 3) printf("%d\n",s[1]);
else if(c==2)
{
scanf("%d%d",&i,&m);
update(1,1,N,i,i+m-1,0);
}
else
{
scanf("%d%d",&i,&m);
update(1,1,N,i,i+m-1,1);
}
}
return 0;
}