#include <fstream>
#include <stdint.h>
#define nmax 100001
#define pmax 200001
using namespace std;
fstream f1("hotel.in", ios::in);
fstream f2("hotel.out", ios::out);
int32_t n, p;
struct arb_int
{
int32_t l, r, total, sum;
} arb[nmax*4];
///arb[poz].total= lungimea secv maxime libere din intervalul coresp lui poz
///arb[poz].l= lungime secv maxime libere care incepe din st din intervalul coresp lui poz
///arb[poz].r= lungime secv maxime libere care incepe din dr din intervalul coresp lui poz
///arb[poz].sum= suma el coresp intervalului lui poz
void citire()
{
f1>>n>>p;
}
int32_t maxim(int32_t a, int32_t b)
{
if(a>b) return a;
else return b;
}
void creare(int32_t poz, int32_t st, int32_t dr)
{
if(st<dr)
{
int32_t mijl=(st+dr)/2;
creare(2*poz, st, mijl);
creare(2*poz+1, mijl+1, dr);
arb[poz].total=maxim(arb[poz*2].total ,maxim(arb[poz*2+1].total, arb[poz*2].r+arb[poz*2+1].l));
arb[poz].l=maxim(arb[poz*2].l, arb[poz*2].total+arb[poz*2+1].l);
arb[poz].r=maxim(arb[poz*2+1].r, arb[poz*2+1].total+arb[poz*2].r);
arb[poz].sum=0;
}
else if(st==dr)
{
arb[poz].total=1;
arb[poz].l=1;
arb[poz].r=1;
arb[poz].sum=0;
}
}
void init(arb_int a)
{
a.total=0;
a.l=0;
a.r=0;
a.sum=0;
}
void functie(int32_t poz)
{
arb[poz].total=maxim(arb[poz*2].total ,maxim(arb[poz*2+1].total, arb[poz*2].r+arb[poz*2+1].l));
if(arb[poz*2].sum==0) arb[poz].l=maxim(arb[poz*2].l, arb[poz*2].total+arb[poz*2+1].l);
else arb[poz].l=arb[poz*2].l;
if(arb[poz*2+1].sum==0) arb[poz].r=maxim(arb[poz*2+1].r, arb[poz*2+1].total+arb[poz*2].r);
else arb[poz].r=arb[poz*2+1].r;
arb[poz].sum=arb[poz*2].sum+arb[poz*2+1].sum;
}
void aduna(int32_t poz, int32_t st, int32_t dr, int32_t x, int32_t y)
{
if(st<dr)
{
int32_t mijl=(st+dr)/2;
if(x<=mijl)
{
aduna(2*poz, st, mijl, x, y);
}
if(mijl<y)
{
aduna(2*poz+1, mijl+1, dr, x, y);
}
////reactualizare
functie(poz);
}
else if(st==dr)
{
///nodul tau va fi ocupat
arb[poz].total=0;
arb[poz].l=0;
arb[poz].r=0;
arb[poz].sum=1;
}
}
void scade(int32_t poz, int32_t st, int32_t dr, int32_t x, int32_t y)
{
if(st<dr)
{
int32_t mijl=(st+dr)/2;
if(x<=mijl)
{
scade(2*poz, st, mijl, x, y);
}
if(mijl<y)
{
scade(2*poz+1, mijl+1, dr, x, y);
}
////reactualizare
functie(poz);
}
else if(st==dr)
{
arb[poz].total=1;
arb[poz].l=1;
arb[poz].r=1;
arb[poz].sum=0;
}
}
void intrebare()
{
int32_t i, v, x, y;
for(i=1; i<=p; i++)
{
f1>>v;
if(v==1) {f1>>x>>y; aduna(1, 1, n, x, x+y-1);}///aduni o unitate la secv x y
if(v==2) {f1>>x>>y; scade(1, 1, n, x, x+y-1);}///scazi o unitate la secv x y
if(v==3) {f2<<arb[1].total<<"\n";}
}
}
int main()
{
citire();
creare(1, 1, n);
intrebare();
return 0;
}