#include <iostream>
#include <cstdio>
#define MAXN 100050
using namespace std;
struct nod
{
int mx, st, dr;
};
nod arb[MAXN];
int n, p;
inline void fil(int ind, int lo, int hi, int tip)
{
arb[ind].mx = arb[ind].st = arb[ind].dr = tip * (hi-lo+1);
}
void update(int lo, int hi, int ind, int qlo, int qhi, int tip)
{
if (qlo <= lo && hi <= qhi) {
if (tip == 2)
fil(ind, lo, hi, 1);
else
fil(ind, lo, hi, 0);
return;
}
int mid = (lo + hi) >> 1;
if (arb[ind].mx == hi-lo+1) {
fil(ind<<1, lo, mid, 1);
fil((ind<<1)+1, mid+1, hi, 1);
}
if (arb[ind].mx == 0) {
fil(ind<<1, lo, mid, 0);
fil((ind<<1)+1, mid+1, hi, 0);
}
if (qlo <= mid)
update(lo, mid, ind<<1, qlo, qhi, tip);
if (qhi > mid)
update(mid+1, hi, (ind<<1)+1, qlo, qhi, tip);
arb[ind].st = arb[ind<<1].st;
arb[ind].dr = arb[(ind<<1)+1].dr;
if (arb[ind<<1].mx == (mid-lo+1))
arb[ind].st += arb[(ind<<1)+1].st;
if (arb[(ind<<1)+1].mx == (hi-mid))
arb[ind].dr += arb[ind<<1].dr;
arb[ind].mx = max(arb[ind<<1].mx, arb[(ind<<1)+1].mx);
arb[ind].mx = max(arb[ind].mx, arb[ind<<1].dr + arb[(ind<<1)+1].st);
}
int main()
{
freopen("hotel.in", "r", stdin);
freopen("hotel.out", "w", stdout);
scanf("%d %d", &n, &p);
arb[1].mx = arb[1].st = arb[1].dr = n;
for (int i = 1; i <= p; i++)
{
int tip, ind, le;
scanf("%d", &tip);
if (tip == 3)
printf("%d\n", arb[1].mx);
else {
scanf("%d %d", &ind, &le);
update(1, n, 1, ind, ind+le-1, tip);
}
}
return 0;
}