#include <bits/stdc++.h>
using namespace std;
ifstream fin("hotel.in");
ofstream fout("hotel.out");
int i,n,v[100005],a[500000],m,st2,dr2,apref[500000],asuf[500000],Max,p,mark[500000];
void build(int nod, int st, int dr){
if(st == dr){
a[nod] = -1;
return;
}
int mij = (st + dr) >> 1;
build(2*nod,st,mij);
build(2*nod+1,mij+1,dr);
}
void update(int nod, int st, int dr, int st1, int dr1){
int mij = (st + dr) >> 1;
if(st == dr){
if(st >= st2 && dr <= dr2 && !mark[nod]){
apref[nod] = 0;
asuf[nod] = 0;
a[nod] = 0;
mark[nod] = 1;
}
else if(!mark[nod]){
apref[nod] = 1;
asuf[nod] = 1;
a[nod] = 1;
}
return;
}
else{
update(2*nod,st,mij,st1,dr1);
update(2*nod+1,mij+1,dr,st1,dr1);
apref[nod] = apref[2*nod+1] + apref[2*nod];
asuf[nod] = asuf[2*nod+1] + asuf[2*nod];
a[nod] = max(max(a[2*nod],a[2*nod+1]),apref[2*nod]+asuf[2*nod+1]);
}
}
void update2(int nod, int st, int dr, int st1, int dr1){
int mij = (st + dr) >> 1;
if(st == dr){
if(st >= st1 && dr <= dr1 && !a[nod]){
apref[nod] = 1;
asuf[nod] = 1;
a[nod] = 1;
mark[nod] = 0;
}
return;
}
else{
update2(2*nod,st,mij,st1,dr1);
update2(2*nod+1,mij+1,dr,st1,dr1);
apref[nod] = apref[2*nod+1] + apref[2*nod];
asuf[nod] = asuf[2*nod+1] + asuf[2*nod];
a[nod] = max(max(a[2*nod],a[2*nod+1]),apref[2*nod]+asuf[2*nod+1]);
}
}
int main()
{
fin>>n>>m;
build(1,1,n);
a[1] = n;
for(i=1;i<=m;i++){
fin>>p;
if(p == 1){
fin>>st2>>dr2;
dr2 = st2 + dr2 - 1;
update(1,1,n,dr2+1,n);
}
else if(p == 2){
fin>>st2>>dr2;
dr2 = st2 + dr2 - 1;
update2(1,1,n,st2,dr2);
}
else
fout << a[1] << '\n';
}
return 0;
}