#include <bits/stdc++.h>
using namespace std;
const int NMAX = 100005;
int N, P;
struct AINT
{
int pref, suff, best, flag;
};
AINT aint[4 * NMAX];
int LeftSon(int node)
{
return 2 * node;
}
int RightSon(int node)
{
return 2 * node + 1;
}
void Propagate(int node, int left, int right)
{
if (left == right || aint[node].flag == 0)
return;
int mid = (left + right) / 2;
if (aint[node].flag == 1)
{
aint[LeftSon(node)] = {0, 0, 0, 1};
aint[RightSon(node)] = {0, 0, 0, 1};
}
else
{
aint[LeftSon(node)] = {mid - left + 1, mid - left + 1, mid - left + 1, 2};
aint[RightSon(node)] = {mid - left + 1, mid - left + 1, mid - left + 1, 2};
}
aint[LeftSon(node)].flag = aint[RightSon(node)].flag = aint[node].flag;
aint[node].flag = 0;
}
void Compute(int node, int left, int right)
{
int mid = (left + right) / 2;
aint[node].pref = aint[RightSon(node)].pref;
if (aint[RightSon(node)].pref == right - mid)
aint[node].pref = aint[LeftSon(node)].pref + (right - mid);
aint[node].suff = aint[LeftSon(node)].suff;
if (aint[LeftSon(node)].suff == mid - left + 1)
aint[node].suff = aint[RightSon(node)].suff + (mid - left + 1);
aint[node].best = max(aint[LeftSon(node)].best, aint[RightSon(node)].best);
aint[node].best = max(aint[node].best, aint[LeftSon(node)].pref + aint[RightSon(node)].suff);
}
void Build(int node, int left, int right)
{
if (left == right)
{
aint[node] = {1, 1, 1, 0};
return;
}
int mid = (left + right) / 2;
Build(LeftSon(node), left, mid);
Build(RightSon(node), mid + 1, right);
Compute(node, left, right);
}
void LazyUpdate(int node, int left, int right, int LeftUpdate, int RightUpdate, int op)
{
Propagate(node, left, right);
if (LeftUpdate <= left && right <= RightUpdate)
{
if (op == 1)
aint[node] = {0, 0, 0, 1};
else
aint[node] = {right - left + 1, right - left + 1, right - left + 1, 2};
return;
}
int mid = (left + right) / 2;
if (LeftUpdate <= mid)
LazyUpdate(LeftSon(node), left, mid, LeftUpdate, RightUpdate, op);
if (RightUpdate >= mid + 1)
LazyUpdate(RightSon(node), mid + 1, right, LeftUpdate, RightUpdate, op);
Compute(node, left, right);
}
int Query()
{
return aint[1].best;
}
int main()
{
ifstream fin("hotel.in");
ofstream fout("hotel.out");
fin >> N >> P;
Build(1, 1, N);
for (int i = 1;i <= P;++i)
{
int op, x, y;
fin >> op;
if (op == 1)
{
fin >> x >> y;
LazyUpdate(1, 1, N, x, x + y - 1, 1);
}
else if (op == 2)
{
fin >> x >> y;
LazyUpdate(1, 1, N, x, x + y - 1, 2);
}
else
fout << Query() << "\n";
}
fin.close();
fout.close();
return 0;
}