#include <fstream>
using namespace std;
ifstream fin("hotel.in");
ofstream fout("hotel.out");
const int NMAX = 100001, INF = 1e9;
int n, v[NMAX], ai[4 * NMAX], lai[4 * NMAX], q, sol;
void build(int nod, int st, int dr){
if(st == dr){
ai[nod] = 1;
return;
}
int mij = (st + dr) / 2;
build(nod * 2, st, mij);
build(nod * 2 + 1, mij + 1, dr);
ai[nod] = ai[nod * 2] + ai[nod * 2 + 1];
}
void update(int nod, int st, int dr, int a, int b, int val){
if(st >= a && dr <= b){
ai[nod] = val;
lai[nod] = 1;
return;
}
if(lai[nod]){
ai[2 * nod] = ai[2 * nod + 1] = ai[nod];
lai[2 * nod] = lai[2 * nod + 1] = 1;
lai[nod] = 0;
}
int mij = (st + dr) / 2;
if(a <= mij) update(nod * 2, st, mij, a, b, val);
if(b > mij) update(nod * 2 + 1, mij + 1, dr, a, b, val);
ai[nod] = ai[nod * 2] + ai[nod * 2 + 1];
}
void query(int nod, int st, int dr, int a, int b){
if(a <= st && dr <= b){
sol = max(sol, ai[nod]);
return;
}
if(lai[nod]){
ai[2 * nod] = ai[2 * nod + 1] = ai[nod];
lai[2 * nod] = lai[2 * nod + 1] = 1;
lai[nod] = 0;
}
int mij = (st + dr) / 2;
if(a <= mij)query(nod * 2, st, mij, a, b);
if(b > mij) query(nod * 2 + 1, mij + 1, dr, a, b);
}
int main()
{
fin >> n >> q;
build(1, 1, n);
for(int i = 1; i <= q; i++){
int c, x, y;
fin >> c;
if(c == 3){
sol = -INF;
query(1, 1, n, 1, n);
fout << sol << '\n';
}
else if(c == 1){
fin >> x >> y;
update(1, 1, n, x, x + y - 1, 0);
}
else{
fin >> x >> y;
update(1, 1, n, x, x + y - 1, 1);
}
}
fin.close();
fout.close();
return 0;
}