#include <fstream>
#include <cmath>
#define DIM 100002
using namespace std;
ifstream f("hotel.in");
ofstream g("hotel.out");
int n, m, flag[4 * DIM], tip, x, y, cobor[4 * DIM];
struct arbore{
int smij, sst, sdr, complet;
}aint[4 * DIM];
void flaguieste(int nod, int st, int dr){
if(flag[nod] == 1){
aint[nod].sst = aint[nod].sdr = aint[nod].smij = dr - st + 1;
aint[nod].complet = 1;
flag[2 * nod] = flag[2 * nod + 1] = flag[nod];
flag[nod] = 0;
}
if(flag[nod] == -1){
aint[nod].sst = aint[nod].sdr = aint[nod].smij = 0;
aint[nod].complet = 0;
flag[2 * nod] = flag[2 * nod + 1] = flag[nod];
flag[nod] = 0;
}
}
void update(int nod, int st, int dr, int a, int b, int val){
if(a <= st && b >= dr){
if(val == 1){
aint[nod].sst = aint[nod].sdr = aint[nod].smij = dr - st + 1;
aint[nod].complet = 1;
}
else{
aint[nod].sst = aint[nod].sdr = aint[nod].smij = 0;
aint[nod].complet = 0;
}
flag[2 * nod] = flag[2 * nod + 1] = val;
flag[nod] = 0;
return;
}
int mid = (st + dr) / 2;
flaguieste(nod, st, dr);
if(a <= mid)
update(2 * nod, st, mid, a, b, val);
if(b > mid)
update(2 * nod + 1, mid + 1, dr, a, b, val);
flaguieste(2 * nod, st, mid);
flaguieste(2 * nod + 1, mid + 1, dr);
aint[nod].smij = max(max(aint[2 * nod].smij, aint[2 * nod + 1].smij), aint[2 * nod].sdr + aint[2 * nod + 1].sst);
if(aint[2 * nod].complet)
aint[nod].sst = aint[2 * nod].sst + aint[2 * nod + 1].sst;
else
aint[nod].sst = aint[2 * nod].sst;
if(aint[2 * nod + 1].complet)
aint[nod].sdr = aint[2 * nod].sdr + aint[2 * nod + 1].sdr;
else
aint[nod].sdr = aint[2 * nod + 1].sdr;
if(aint[nod].sst == aint[nod].sdr && aint[nod].sst != 0)
aint[nod].complet = 1;
else
aint[nod].complet = 0;
}
int main()
{
f>>n>>m;
update(1, 1, n, 1, n, 1);
for(int i = 1; i <= m; ++ i){
f>>tip;
if(tip == 1){
f>>x>>y;
update(1, 1, n, x, x + y - 1, -1);
}
if(tip == 2){
f>>x>>y;
update(1, 1, n, x, x + y - 1, 1);
}
if(tip == 3){
//query(1, 1, n);
g<<max(max(aint[1].smij, aint[2].sst), aint[1].sdr)<<'\n';
}
}
return 0;
}