#include <bits/stdc++.h>
using namespace std;
struct node {
int l, r, val;
};
int n, q;
node t[1<<20];
void build(int p, int L, int R) {
t[p] = {R-L+1,R-L+1,R-L+1};
if (L == R) return;
int M = (L + R) / 2;
build(p*2, L, M);
build(p*2+1, M+1, R);
}
void update(int p, int L, int R, int l, int r, bool f) {
if (L > R) return;
if (L > r || R < l) return;
if (l <= L && R <= r) {
if (f) t[p] = {R-L+1,R-L+1,R-L+1};
else t[p] = {0,0,0};
return;
}
int M = (L + R) / 2;
if (t[p].val == 0) t[p*2] = {0,0,0}, t[p*2+1] = {0,0,0};
if (t[p].val == R - L + 1) t[p*2] = {M-L+1,M-L+1,M-L+1}, t[p*2+1] = {R-M,R-M,R-M};
update(p*2,L,M,l,r,f);
update(p*2+1,M+1,R,l,r,f);
t[p].l = t[p*2].l;
if (t[p*2].l == M-L+1) t[p].l += t[p*2+1].l;
t[p].r = t[p*2+1].r;
if (t[p*2+1].r == R-M) t[p].r += t[p*2].r;
t[p].val = max(max(t[p*2].val,t[p*2+1].val), max(max(t[p].l,t[p].r), t[p*2].r + t[p*2+1].l));
}
int main() {
freopen("turist.in","r",stdin);
freopen("turist.out","w",stdout);
scanf("%d %d", &n, &q);
build(1,1,n);
while (q--) {
int k, x, y;
cin >> k;
if (k == 1) scanf("%d %d", &x, &y), update(1,1,n,x,x+y-1,0);
if (k == 2) scanf("%d %d", &x, &y), update(1,1,n,x,x+y-1,1);
if (k == 3) printf("%d\n", t[1].val);
}
}