{$APPTYPE CONSOLE}
{$C+,Q+,R+}

uses SysUtils, Math;

type integer = longint;

const MAXN = 100000;

var n, k, p, i, a, b, empty, sum, res: integer;
  c: char;
  error: boolean;
  head: array[ 1 .. MAXN ] of integer;
  next, fuel: array[ 0 .. MAXN ] of integer;

begin
  assign( input, 'ship.in' ); reset( input );
  assign( output, 'ship.out' ); rewrite( output );
  readln( n, k, p );
  assert( ( 1 <= n ) and ( n <= MAXN ) and ( 1 <= k ) and ( k <= MAXN ) and
      ( 1 <= p ) and ( p <= MAXN ), 'Bad n, k or p' );
  error := false;
  empty := 0;
  sum := 0;
  res := 0;
  for i := 1 to n do begin
    readln( c, a, b );
    assert( ( c = '+' ) or ( c = '-' ), 'Line must start with + or -' );
    assert( ( 1 <= a ) and ( a <= k ), 'Unknown type of fuel' );
    if ( c = '+' ) then begin
      inc( empty );
      next[empty] := head[a];
      head[a] := empty;
      fuel[empty] := b;
      inc( sum );
      error := error or ( sum > p );
      res := max( res, sum );
    end else begin
      error := error or ( fuel[head[a]] <> b );
      head[a] := next[head[a]];
      dec( sum );
    end;
  end;
  if ( error or ( sum <> 0 ) ) then writeln( 'Error' )
  else writeln( res );
end.
