#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;
#define nmax 100010
#define leftSon (node << 1)
#define rightSon ((node << 1) + 1)
struct data
{
int left, right, best, used;
}Aint[4 * nmax];
int N, M, X, Y, C;
void BuildTree(int node, int left, int right)
{
Aint[node].left = Aint[node].right = Aint[node].best = right - left + 1;
Aint[node].used = -1;
if(left == right) return ;
int mid = (left + right) / 2;
BuildTree(leftSon, left, mid);
BuildTree(rightSon, mid + 1, right);
}
void Update(int node, int left, int right, int leftRange, int rightRange, int type)
{
if(leftRange <= left && right <= rightRange)
{
Aint[node].used = type;
Aint[node].left = Aint[node].right = Aint[node].best = type * (right - left + 1);
return ;
}
int mid = (left + right) / 2;
if(Aint[node].used != -1)
{
Update(leftSon, left, mid, left, mid, Aint[node].used);
Update(rightSon, mid + 1, right, mid + 1, right, Aint[node].used);
Aint[node].used = -1;
}
if(leftRange <= mid) Update(leftSon, left, mid, leftRange, rightRange, type);
if(mid < rightRange) Update(rightSon, mid + 1, right, leftRange, rightRange, type);
Aint[node].best = max(max(Aint[leftSon].best, Aint[rightSon].best), Aint[leftSon].right + Aint[rightSon].left);
if(Aint[leftSon].left == mid - left + 1)
Aint[node].left = Aint[leftSon].left + Aint[rightSon].left;
else
Aint[node].left = Aint[leftSon].left;
if(Aint[rightSon].right == right - mid)
Aint[node].right = Aint[leftSon].right + Aint[rightSon].right;
else
Aint[node].right = Aint[rightSon].right;
}
int main()
{
freopen("hotel.in", "r", stdin);
freopen("hotel.out", "w", stdout);
scanf("%i %i", &N, &M);
BuildTree(1, 1, N);
for(int i = 1; i <= M; i++)
{
scanf("%i", &C);
if(C < 3)
{
scanf("%i %i", &X, &Y);
Update(1, 1, N, X, X + Y - 1, C - 1);
continue;
}
printf("%i\n", Aint[1].best);
}
return 0;
}