program hotel;
type rec=record
biggest,left,right:longint;
end;
var bufin,bufout:array [1..100000] of byte;
n,p,i,x,y,op:longint;
t:array[1..400000] of rec;
function max(u,v:longint):longint;
begin
if u>v then max:=u else max:=v;
end;
function min(u,v:longint):longint;
begin
if u>v then min:=v else min:=u;
end;
procedure build(nod,tl,tr:longint);
var tm :longint;
begin
if tl=tr then
begin
t[nod].biggest:=1;
t[nod].left:=1;
t[nod].right:=1;
end else
begin
tm:=(tl+tr) shr 1;
build(nod shl 1,tl,tm);
build(nod shl 1+1,tm+1,tr);
if t[nod shl 1].left=tm-tl+1
then t[nod].left:=tm-tl+1+t[nod shl 1+1].left
else t[nod].left:=t[nod shl 1].left;
if t[nod shl 1 +1].right=tr-tm
then t[nod].right:=tr-tm+t[nod shl 1].right
else t[nod].right:=t[nod shl 1+1].right;
t[nod].biggest:=max(max(t[nod shl 1].biggest,t[nod shl 1+1].biggest),
t[nod shl 1].right+t[nod shl 1+1].left);
end;
end;
procedure update1(nod,tl,tr,l,r:longint);
var tm:longint;
begin
if l<=r then
if (l=tl)and(r=tr) then
begin
t[nod].biggest:=0;
t[nod].left:=0;
t[nod].right:=0;
end else
begin
tm:=(tl+tr) shr 1;
if t[nod].biggest=0 then
begin
t[nod shl 1].biggest:=0;
t[nod shl 1+1].biggest:=0;
t[nod shl 1].left:=0;
t[nod shl 1+1].left:=0;
t[nod shl 1].right:=0;
t[nod shl 1+1].right:=0;
end else
if t[nod].biggest=tr-tl+1 then
begin
t[nod shl 1].biggest:=tm-tl+1;
t[nod shl 1+1].biggest:=tr-tm;
t[nod shl 1].left:=tm-tl+1;
t[nod shl 1+1].left:=tr-tm;
t[nod shl 1].right:=tm-tl+1;
t[nod shl 1+1].right:=tr-tm;
end;
update1(nod shl 1,tl,tm,l,min(r,tm));
update1(nod shl 1+1,tm+1,tr,max(tm+1,l),r);
if t[nod shl 1].left=tm-tl+1
then t[nod].left:=tm-tl+1+t[nod shl 1+1].left
else t[nod].left:=t[nod shl 1].left;
if t[nod shl 1 +1].right=tr-tm
then t[nod].right:=tr-tm+t[nod shl 1].right
else t[nod].right:=t[nod shl 1+1].right;
t[nod].biggest:=max(max(t[nod shl 1].biggest,t[nod shl 1+1].biggest),
t[nod shl 1].right+t[nod shl 1+1].left);
end;
end;
procedure update2(nod,tl,tr,l,r:longint);
var tm:longint;
begin
if l<=r then
if (l=tl)and(r=tr) then
begin
t[nod].biggest:=tr+1-tl;
t[nod].left:=tr+1-tl;
t[nod].right:=tr+1-tl;
end else
begin
tm:=(tl+tr) shr 1;
if t[nod].biggest=0 then
begin
t[nod shl 1].biggest:=0;
t[nod shl 1+1].biggest:=0;
t[nod shl 1].left:=0;
t[nod shl 1+1].left:=0;
t[nod shl 1].right:=0;
t[nod shl 1+1].right:=0;
end else
if t[nod].biggest=tr-tl+1 then
begin
t[nod shl 1].biggest:=tm-tl+1;
t[nod shl 1+1].biggest:=tr-tm;
t[nod shl 1].left:=tm-tl+1;
t[nod shl 1+1].left:=tr-tm;
t[nod shl 1].right:=tm-tl+1;
t[nod shl 1+1].right:=tr-tm;
end;
update2(nod shl 1,tl,tm,l,min(r,tm));
update2(nod shl 1+1,tm+1,tr,max(tm+1,l),r);
if t[nod shl 1].left=tm-tl+1
then t[nod].left:=tm-tl+1+t[nod shl 1+1].left
else t[nod].left:=t[nod shl 1].left;
if t[nod shl 1 +1].right=tr-tm
then t[nod].right:=tr-tm+t[nod shl 1].right
else t[nod].right:=t[nod shl 1+1].right;
t[nod].biggest:=max(max(t[nod shl 1].biggest,t[nod shl 1+1].biggest),
t[nod shl 1].right+t[nod shl 1+1].left);
end;
end;
begin
assign(input,'hotel.in');
reset(input);
settextbuf(input,bufin);
assign(output,'hotel.out');
rewrite(output);
settextbuf(output,bufout);
readln(n,p);
build(1,1,n);
for i:=1 to p do
begin
read(op);
if op=3 then writeln(t[1].biggest) else
begin
read(x,y);
if op=1 then update1(1,1,n,x,x+y-1)
else update2(1,1,n,x,x+y-1);
end;
readln;
end;
close(output);
end.