#include <fstream>
#include <iostream>
using namespace std;
struct elem {
int lazy = -1, secv = 0, pre = 0, suf = 0;
};
elem v[263000];
elem fusion(elem a, int st_a, int dr_a, elem b, int st_b, int dr_b ) {
elem r;
r.secv = max( a.suf + b.pre, max( a.secv, b.secv ) );
r.pre = a.pre;
if (a.pre == dr_a - st_a + 1) {
r.pre += b.pre;
}
r.suf = b.suf;
if (b.suf == dr_b - st_b + 1) {
r.suf += a.suf;
}
return r;
}
void propagate(int nod, int st, int dr) {
if (v[nod].lazy == 0) {
v[nod].secv = v[nod].pre = v[nod].suf = dr - st + 1;
}
else if (v[nod].lazy == 1) {
v[nod].secv = v[nod].pre = v[nod].suf = 0;
}
if ( v[nod].lazy != -1 && st < dr) {
v[nod * 2].lazy = v[nod * 2 + 1].lazy = v[nod].lazy;
}
v[nod].lazy = -1;
}
void modif(int nod, int st, int dr, int x, int y, int val) {
int mij = ( st + dr ) / 2;
propagate( nod, st, dr );
if (x <= st && dr <= y) {
v[nod].lazy = val;
}
else {
if (x <= mij) {
modif( nod * 2, st, mij, x, y, val );
}
if (y > mij) {
modif( nod * 2 + 1, mij + 1, dr, x, y, val );
}
propagate( nod * 2, st, mij );
propagate( nod * 2 + 1, mij + 1, dr );
v[nod] = fusion( v[nod * 2], st, mij, v[nod * 2 + 1], mij + 1, dr );
}
//cout << nod << ' ' << st << ' ' << dr << ' ' << x << ' ' << y << ' ' << v[nod].lazy << ' ' << v[nod].secv << ' ' << v[nod].pre << ' ' << v[nod].suf << '\n';
}
int main() {
int n, p, i, tip, x, y;
ifstream fin( "hotel.in" );
ofstream fout( "hotel.out" );
fin >> n >> p;
for (i = 0; i < n; i++) {
modif( 1, 0, n - 1, i, i, 0 );
//cout << '\n' << '\n';
}
/*cout << '\n' << '\n';
cout << '\n' << '\n';
cout << '\n' << '\n';*/
for (i = 0; i < p; i++) {
fin >> tip;
if (tip == 1) {
fin >> x >> y;
x--;
modif( 1, 0, n - 1, x, x + y - 1, 1 );
}
else if (tip == 2) {
fin >> x >> y;
x--;
modif( 1, 0, n - 1, x, x + y - 1, 0 );
}
else {
fout << v[1].secv << '\n';
}
//cout << '\n' << '\n';
}
return 0;
}