{$APPTYPE CONSOLE}

type integer=longint;
var
  ship : array [1 .. 1000000, 1 .. 2] of integer;
  boxes : array [1 .. 1000] of integer;
  stack : array [1 .. 1000000] of integer;
  pointer : integer;
  n, k, p, max, t, i, s1, s2 : integer;
  c : char;

procedure error;
begin
  writeln ('Error');
  close (input); close (output);
  halt (0)
end;  
  
begin
  assign (input, 'ship.in');
  reset (input);
  assign (output, 'ship.out');
  rewrite (output);
  readln (n, k, p);
  pointer := n;
  for i := 1 to n do 
    stack [i] := i;
  for i := 1 to k do 
    boxes [i] := 0;
  max := 0;	
  t := 0;	
  for i := 1 to n do begin
    read(c);
	readln (s1, s2);
	if c = '+' then begin
	  inc (t);
	  if t > max then max := t;
	  if t > p then error;
	  ship [stack [pointer], 1] := s2;
	  ship [stack [pointer], 2] := boxes [s1];
	  boxes [s1] := stack [pointer];
	  dec (pointer)
	end else begin
      if boxes [s1] = 0 then error;
	  if ship [boxes [s1], 1] <> s2 then error;
	  dec (t);
	  inc (pointer);
	  stack [pointer] := boxes [s1];
	  boxes [s1] := ship [boxes [s1], 2]
	end  
  end;
  if t > 0 then error;
  writeln (max);
  close (input); close (output)
end.
