#include <iostream>
#include <fstream>
using namespace std;
ifstream cint("hotel.in");
ofstream coutt("hotel.out");
int aint[400005], pref[400005], suf[400005],lung[400005],cs[400005],cd[400005],fin[400005],lz[400005];
int n,p,cer,cnt=0;
void build()
{
int put=1;
while(put<n)
put*=2;
n=put;
for(int i=n; i<=2*n-1; i++)
aint[i]=1,pref[i]=1,suf[i]=1,lung[i]=1,cs[i]=i-n+1,cd[i]=i-n+1;
for(int i=n-1; i>=1; i--)
{
lung[i]=2*lung[i*2];
aint[i]=aint[i*2]+aint[i*2+1];
pref[i]=pref[i*2]+pref[i*2+1];
suf[i]=suf[i*2]+suf[i*2+1];
cs[i]=cs[i*2];
cd[i]=cd[i*2+1];
}
}
void aplica(int nod, int t)
{
if (t == 2)
{
aint[nod] = lung[nod];
pref[nod] = lung[nod];
suf[nod] = lung[nod];
}
else
{
aint[nod] = 0;
pref[nod] = 0;
suf[nod] = 0;
}
lz[nod] = t;
}
void push(int nod)
{
if (lz[nod] != 0)
{
aplica(2 * nod, lz[nod]);
aplica(2 * nod + 1, lz[nod]);
lz[nod] = 0;
}
}
void functieptot(int nod, int x, int y, int t)
{
if (cd[nod] < x || cs[nod] > y)
return;
if (x <= cs[nod] && cd[nod] <= y)
{
aplica(nod, t);
return;
}
push(nod);
functieptot(2 * nod, x, y, t);
functieptot(2 * nod + 1, x, y, t);
int L = 2 * nod;
int R = 2 * nod + 1;
aint[nod] = max(max(aint[L], aint[R]), suf[L] + pref[R]);
if (pref[L] == lung[L])
pref[nod] = pref[L] + pref[R];
else
pref[nod] = pref[L];
if (suf[R] == lung[R])
suf[nod] = suf[L] + suf[R];
else
suf[nod] = suf[R];
}
void intquer(int st, int dr, int nodcur)
{
if(nodcur>=n)
return;
push(nodcur);
int son=2*nodcur;
if(cs[son]>=st&&cd[son]<=dr)
{
cnt++;
fin[cnt]=son;
}
else
{
if(cs[son]<=dr && cd[son]>=st)
intquer(st, dr, son);
}
son++;
if(cs[son]>=st&&cd[son]<=dr)
{
cnt++;
fin[cnt]=son;
}
else
{
if(cs[son]<=dr && cd[son]>=st)
intquer(st, dr, son);
}
}
int ans(int st, int dr)
{
cnt=0;
intquer(st, dr, 1);
int maxx=0, maxxpref=0;
maxx=aint[fin[1]];
maxxpref=suf[fin[1]];
// coutt<<pref[fin[1]]<<" "<<suf[fin[1]]<<" "<<aint[fin[1]]<<" "<<fin[1]<<" "<<cs[fin[1]]<<" "<<cd[fin[1]]<<'\n';
for(int i=2;i<=cnt;i++)
{
if(maxx<max(aint[fin[i]], maxxpref+pref[fin[i]]))
maxx=max(aint[fin[i]], maxxpref+pref[fin[i]]);
if(suf[fin[i]]==lung[fin[i]])
maxxpref=maxxpref+suf[fin[i]];
else
maxxpref=suf[fin[i]];
//coutt<<pref[fin[i]]<<" "<<suf[fin[i]]<<" "<<aint[fin[i]]<<" "<<fin[i]<<" "<<cs[fin[i]]<<" "<<cd[fin[i]]<<'\n';
}
return maxx;
}
int main()
{
int x, m;
cint>>n>>p;
int cn = n;
build();
while (p--)
{
cint>> cer;
if (cer==1)
{
cint>>x>>m;
functieptot(1, x, x+m-1, 1);
}
else if (cer==2)
{
cint>>x>>m;
functieptot(1, x, x+m-1, 2);
}
else if (cer==3)
coutt<<ans(1, cn)<<'\n';
}
return 0;
}