{
ZADATAK: Atomi
JEZIK: PASCAL
}

program Atomi;

const
  InputData  = 'atomi.in';
  OutputData = 'atomi.out';

var
  N, M : LongInt;
  arr  : Array[1..250000] of LongInt;


procedure Main;

  procedure RemoveElement(const AIndex : LongInt);
  var
    C1        : LongInt;
    CursorPos : LongInt;
  begin
    If arr[AIndex] <> 0 Then
    Begin
      CursorPos := AIndex - 1;
      While (arr[CursorPos] <> 0) and
            (CursorPos > 0) Do
      Begin
        arr[CursorPos] := arr[CursorPos] - arr[AIndex];
        CursorPos := CursorPos - 1;
      End;
    End;
  end;

  procedure AddElement(const AIndex : LongInt);
  var
    CursorPos : LongInt;
  begin
    If arr[AIndex] = 0 Then
    Begin
      arr[AIndex] := 1;

      If (AIndex < N) and
         (arr[AIndex + 1] <> 0) Then
        arr[AIndex] := arr[AIndex + 1] + 1;

      If arr[AIndex - 1] <> 0 Then
      Begin
        CursorPos := AIndex - 1;
        While (arr[CursorPos] <> 0) and
              (CursorPos > 0) Do
        Begin
          arr[CursorPos] := arr[CursorPos + 1] + 1;
          CursorPos := CursorPos - 1;
        End;
      End;
    End;
  end;

var
  SFile  : TextFile;
  TFile  : TextFile;
  C1, C2 : LongInt;
  op     : Byte;
  ele    : LongInt;
  X1, X2 : LongInt;
  maxl   : LongInt;
begin
  Assign(SFile, InputData);
  Assign(TFile, OutputData);
  Reset(SFile);
  Rewrite(TFile);

    Read(SFile, N, M);

    For C1 := 1 to M Do
    Begin
      Read(SFile, op);
      Case op of
        0 : Begin
              Read(SFile, ele);
              RemoveElement(ele);
            End;
        1 : Begin
              Read(SFile, ele);
              AddElement(ele);
            End;
        2 : Begin
              Read(SFile, X1, X2);
              maxl := 0;
              For C2 := X1 to X2 Do
                If arr[C2] > maxl Then
                  maxl := arr[C2];

              WriteLn(TFile, maxl);
            End;
      End;
    End;

  Close(TFile);
  Close(SFile);
end;


begin
  Main;
end.