#include <bits/stdc++.h>
int pf[400000], sf[400000], t[400000], mx[400000];
int max( int a, int b ) {
return a > b ? a : b;
}
void arbore( int st, int dr, int p ) {
if ( st == dr ) {
pf[p] = sf[p] = t[p] = mx[p] = 1;
} else {
arbore( st, ( st + dr ) / 2, 2 * p );
arbore( ( st + dr ) / 2 + 1, dr, 2 * p + 1 );
if ( pf[2 * p] == t[2 * p] ) {
pf[p] = pf[2 * p] + pf[2 * p + 1];
} else {
pf[p] = pf[2 * p];
}
if ( sf[2 * p + 1] == t[2 * p + 1] ) {
sf[p] = sf[2 * p + 1] + sf[2 * p];
} else {
sf[p] = sf[2 * p + 1];
}
t[p] = t[2 * p] + t[2 * p + 1];
mx[p] = max( max( mx[2 * p], mx[2 * p + 1] ), max( pf[p], sf[p] ) );
}
}
void update( int st, int dr, int p, int x, int i, int j ) {
if ( st == dr ) {
pf[p] = sf[p] = x;
} else {
if ( i <= ( st + dr ) / 2 )
update( st, ( st + dr ) / 2, 2 * p, x, i, j );
if ( j >= ( st + dr ) / 2 + 1 )
update( ( st + dr ) / 2 + 1, dr, 2 * p + 1, x, i, j );
if ( pf[2 * p] == t[2 * p] ) {
pf[p] = pf[2 * p] + pf[2 * p + 1];
} else {
pf[p] = pf[2 * p];
}
if ( sf[2 * p + 1] == t[2 * p + 1] ) {
sf[p] = sf[2 * p + 1] + sf[2 * p];
} else {
sf[p] = sf[2 * p + 1];
}
mx[p] = max( max( mx[2 * p], mx[2 * p + 1] ), max( pf[p], sf[p] ) );
mx[p] = max( mx[p], sf[2 * p] + pf[2 * p + 1] );
}
}
int main() {
FILE *fin, *fout;
int n, p, i, c, a, b, x;
fin = fopen( "hotel.in", "r" );
fout = fopen( "hotel.out", "w" );
fscanf( fin, "%d%d", &n, &p );
arbore( 1, n, 1 );
for ( i = 0; i < p; i++ ) {
fscanf( fin, "%d", &c );
if ( c == 3 ) {
fprintf( fout, "%d\n", mx[1] );
} else if ( c == 1 ) {
fscanf( fin, "%d%d", &a, &b );
x = 0;
update( 1, n, 1, x, a, b + a - 1 );
} else if ( c == 2 ) {
fscanf( fin, "%d%d", &a, &b );
x = 1;
update( 1, n, 1, x, a, b + a - 1 );
}
}
fclose( fin );
fclose( fout );
return 0;
}