#include <cstdio>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <algorithm>
#include <utility>
#include <string>
#include <functional>
#include <sstream>
#include <fstream>
#include <iostream>
#include <cstring>
#include <cstdlib>
using namespace std;
#define FOR(i,a,b) for (i=a;i<=b;i++)
#define fori(it,v) for (it=(v).begin();it!=(v).end();it++)
#define pb push_back
#define mp make_pair
#define fs first
#define ss second
#define all(c) c.begin(),c.end()
#define pf push_front
#define popb pop_back
#define popf pop_front
#define NMAX 1 << 18
typedef struct ceva2
{
int tip, st, dr, max;
}ceva;
ceva T[NMAX];
int N, P, st_v, dr_v, middle, t ;
inline int max4( int a, int b, int c, int d, int e )
{
return max(a,max(b,max(c,max(d,e))));
}
void modify( ceva & T, int t, int value )
{
T.tip = t;
if( t )
value = 0;
T.st = T.dr = T.max = value;
}
void update( int nod, int st, int dr, int t )
{
int half;
if( st >= st_v && dr <= dr_v )
modify( T[nod], t, dr - st + 1 );
else
{
half = ( st + dr ) >> 1;
if( T[nod].tip != 2 )
{
modify( T[2*nod], T[nod].tip, half - st + 1 );
modify( T[2*nod+1], T[nod].tip, dr - half );
}
if( st_v <= half )
update( 2 * nod, st, half, t );
if( dr_v > half )
update( 2 * nod + 1, half + 1, dr, t );
middle = T[2*nod].dr + T[2*nod+1].st;
T[nod].st = !T[2*nod].tip ? T[2*nod].st + T[2*nod+1].st : T[2*nod].st;
T[nod].dr = !T[2*nod+1].tip ? T[2*nod].dr + T[2*nod+1].dr : T[2*nod+1].dr;
T[nod].max =max4( T[nod].st, T[nod].dr, middle, T[2*nod].max, T[2*nod+1].max );
if( T[2*nod].tip == T[2*nod+1].tip )
T[nod].tip = T[2*nod].tip;
else
T[nod].tip = 2;
}
}
void build( int nod, int st, int dr )
{
int half = ( st + dr ) >> 1;
if( st == dr )
modify( T[nod], 0, 1 );
else
{
modify( T[nod], 0, dr - st + 1 );
build( 2 * nod, st, half );
build( 2 * nod + 1, half + 1, dr );
}
}
int main()
{
FILE * in = fopen("hotel.in", "r" );
FILE * out = fopen("hotel.out", "w" );
fscanf( in, "%d%d",&N,&P);
build( 1, 1, N );
while( P-- )
{
fscanf( in, "%d", &t );
if( t == 3 )
fprintf( out, "%d\n", T[1].max );
else
{
fscanf(in, "%d%d", &st_v, &dr_v );
dr_v = st_v + dr_v - 1;
update( 1, 1, N, 2 - t );
}
}
fclose(fin);
fclose(fout);
return 0;
}