#include <bits/stdc++.h>
#define nmax 100005
using namespace std;
ifstream in("hotel.in");
ofstream out("hotel.out");
int n,p,lmax[4*nmax],stmax[4*nmax],drmax[4*nmax],lazy[4*nmax];
void update(int st, int dr, int poz, int a, int b, int state){
if(lazy[poz]){
if(lazy[poz]==1){
stmax[poz] = 0;
drmax[poz] = 0;
lmax[poz] = 0;
}
else{
stmax[poz] = dr-st+1;
drmax[poz] = dr-st+1;
lmax[poz] = dr-st+1;
}
lazy[poz*2] = lazy[poz*2+1] = lazy[poz];
lazy[poz]=0;
}
if(st>b || dr<a) return;
if(st>=a && dr<=b){
if(state==2){
stmax[poz] = dr-st+1;
drmax[poz] = dr-st+1;
lmax[poz] = dr-st+1;
}
else{
stmax[poz]=0;
drmax[poz]=0;
lmax[poz]=0;
}
lazy[poz*2] = lazy[poz*2+1] = state;
return;
}
int mid = (st+dr)/2;
update(st,mid,2*poz,a,b,state);
update(mid+1,dr,2*poz+1,a,b,state);
if(lmax[2*poz] == mid-st+1)
{
stmax[poz] = lmax[2*poz]+stmax[2*poz+1];
}
else
{
stmax[poz] = stmax[2*poz];
}
if(lmax[2*poz+1] == dr-mid){
drmax[poz] = lmax[2*poz+1]+drmax[2*poz];
}
else{
drmax[poz] = drmax[2*poz+1];
}
lmax[poz] = max(max(drmax[2*poz]+stmax[2*poz+1],max(lmax[poz*2],lmax[poz*2+1])),max(stmax[poz],drmax[poz]));
}
void read_n_solve(){
in >> n >> p;
update(1,n,1,1,n,2);
for(int i=1; i<=p; i++){
int c,a,b;
in >> c;
if(c==1){
in >> a >> b;
update(1,n,1,a,a+b-1,c);
}
else if(c==2){
in >> a >> b;
update(1,n,1,a,a+b-1,c);
}
else{
out << lmax[1] << '\n';
}
}
}
int main(){
read_n_solve();
}