#include <cstdio>
#include <algorithm>
using namespace std;
#define FILEIN "hotel.in"
#define FILEOUT "hotel.out"
int L[262145];
int R[262145];
int V[262145];
int a, b, v, N, M;
void update(int nod, int l, int r) {
if (a <= l && r <= b) {
V[nod] = L[nod] = R[nod] = (r - l + 1) * v;
return;
}
int m = (l+r)/2;
if (v) {
if (!V[nod])
V[2*nod] = L[2*nod] = R[2*nod] = 0,
V[2*nod+1] = L[2*nod+1] = R[2*nod+1] = 0,
V[nod] = r - l + 1;
} else {
if (V[nod] == r - l + 1) {
V[2*nod] = L[2*nod] = R[2*nod] = m - l + 1;
V[2*nod+1] = L[2*nod+1] = R[2*nod+1] = r - m;
V[nod] = L[nod] = R[nod] = 0;
}
}
if (a <= m) update(2*nod , l , m);
if (m < b) update(2*nod+1, m+1, r);
L[nod] = L[2*nod];
if (V[2*nod] == m - l + 1)
L[nod] = V[2*nod] + L[2*nod+1];
R[nod] = R[2*nod+1];
if (V[2*nod+1] == r - m)
R[nod] = V[2*nod+1] + R[2*nod];
V[nod] = 0;
V[nod] = max(V[nod], R[2*nod] + L[2*nod+1]);
V[nod] = max(V[nod], V[2*nod]);
V[nod] = max(V[nod], V[2*nod+1]);
V[nod] = max(V[nod], L[nod]);
V[nod] = max(V[nod], R[nod]);
}
int main() {
freopen(FILEIN, "r", stdin);
freopen(FILEOUT, "w", stdout);
scanf("%d %d", &N, &M);
a = 1, b = N, v = 1;
update(1, 1, N);
for (; M; M--) {
int T, x, y;
scanf("%d", &T);
if (T == 3) {
printf("%d\n", V[1]);
} else scanf("%d %d", &x, &y);
if (T == 2) {
a = x, b = x + y - 1, v = 1;
update(1, 1, N);
}
if (T == 1) {
a = x, b = x + y - 1, v = 0;
update(1, 1, N);
}
}
return 0;
}