#include <stdio.h>
#define nmax 300002
#define inf nmax
int n, m, bt[nmax][3];
int max(int a, int b)
{
return(a < b ? b : a);
}
void update(int nod, int left, int right, int a, int b, int x)
{
int k;
if (left == right)
{
bt[nod][0] = bt[nod][1] = bt[nod][2] = x;
return;
}
k = (left + right) >> 1;
if (a <= k) update(nod << 1,left ,k , a, b, x);
if (a + b - 1> k) update((nod << 1) + 1, k + 1, right, a, b, x);
bt[nod][1] = max(max(bt[nod << 1][1], bt[(nod << 1) + 1][1]),
bt[nod << 1][2] + bt[(nod << 1) + 1][0]);
if (bt[nod << 1][1] == (right - left + 2) / 2)
bt[nod][0] = bt[(nod << 1) + 1][0] + bt[nod << 1][1];
else bt[nod][0] = bt[nod << 1][0];
if (bt[(nod << 1) + 1][1] == (right - left + 1) / 2)
bt[nod][2] = bt[nod << 1][2] + bt[(nod << 1) + 1][1];
else bt[nod][2] = bt[(nod << 1) + 1][2];
}
int main()
{
int a, b, c;
freopen("hotel.in", "rt", stdin);
freopen("hotel.out", "wt", stdout);
scanf("%d %d", &n, &m);
for (int i = 1; i <= 3 * n; ++i)
bt[i][0] = bt[i][1] = bt[i][2] = inf;
update(1, 1, n, 1, n, 1);
for (int i = 1; i <= m; ++i)
{
scanf("%d", &c);
if (c != 3)
{
scanf("%d %d", &a, &b);
update(1, 1, n, a, b, (c + 1) % 2);
}
else
printf("%d\n", bt[1][1]);
}
}