#include <fstream>
using namespace std;
ifstream cin ("hotel.in");
ofstream cout ("hotel.out");
const int MAX_n = 200000;
int n, q;
struct nod
{
int gg;
int max_st;
int max_dr;
bool liber;
bool plin;
};
nod ArbInt[4 * MAX_n];
nod Create_liber(int st, int dr)
{
int lgm = dr - st + 1;
return nod {lgm, lgm, lgm, 1, 0};
}
nod Create_plin()
{
return {0, 0, 0, 0, 1};
}
nod Join(nod A, nod B)
{
nod nod;
nod.gg = max(max(A.gg, B.gg), A.max_dr + B.max_st);
if (B.liber)
nod.max_dr = A.max_dr + B.max_dr;
else
nod.max_dr = B.max_dr;
if (A.liber)
nod.max_st = A.max_st + B.max_st;
else
nod.max_st = A.max_st;
if(A.liber && B.liber)
nod.liber = 1;
else
nod.liber = 0;
if(A.plin && B.plin)
nod.plin = 1;
else
nod.plin = 0;
return nod;
}
void Build(int nod, int st, int dr)
{
if (st == dr)
{
ArbInt[nod] = Create_liber(st, dr);
return;
}
int mid = (st + dr) / 2;
Build(2 * nod, st, mid);
Build(2 * nod + 1, mid + 1, dr);
ArbInt[nod] = Join(ArbInt[2 * nod], ArbInt[2 * nod + 1]);
}
void Update(int nod, int st, int dr, int l, int r, bool liber)
{
int mid = (st + dr) / 2;
if (ArbInt[nod].liber)
{
ArbInt[2 * nod] = Create_liber(st, mid);
ArbInt[2 * nod + 1] = Create_liber(mid + 1, dr);
}
if (ArbInt[nod].plin)
{
ArbInt[2 * nod] = Create_plin();
ArbInt[2 * nod + 1] = Create_plin();
}
if (l <= st && dr <= r)
{
if(liber == 0)
ArbInt[nod] = Create_liber(st, dr);
else
ArbInt[nod] = Create_plin();
return;
}
if (l <= mid)
Update(2 * nod, st, mid, l, r, liber);
if (mid < r)
Update(2 * nod + 1, mid + 1, dr, l, r, liber);
ArbInt[nod] = Join(ArbInt[2 * nod], ArbInt[2 * nod + 1]);
}
int main()
{
scanf("%d %d",&n,&q);
Build(1, 1, n);
for(int i = 1; i <= q; i++)
{
int tip, x, y;
scanf("%d",&tip);
if (tip == 1)
{
scanf("%d %d",&x,&y);
Update(1, 1, n, x, x + y - 1, 1);
}
else if (tip == 2)
{
scanf("%d %d",&x,&y);
Update(1, 1, n, x, x + y - 1, 0);
}
else
printf("%d\n",ArbInt[1].gg);
}
return 0;
}