import java.util.Scanner;
import java.util.LinkedList;
import java.util.ArrayList;
import java.io.File;
import java.io.PrintWriter;

/**
 * Created by IntelliJ IDEA.
 * User: m09fpv
 * Date: 25.11.2009
 * Time: 19:27:24
 * To change this template use File | Settings | File Templates.
 */
public class ship {
  public static void main(String[]  args) throws Exception {
   Scanner in=new  Scanner(new File("ship.in"));
   PrintWriter out=new PrintWriter(new File("ship.out"));
   ArrayList<LinkedList<Integer>> q=new ArrayList<LinkedList<Integer>>();
   ArrayList<Integer> f=new ArrayList<Integer>();
   String s;  int a,b,cnt;
   boolean x=true;
   cnt=0;
   int n=in.nextInt();
   int k=in.nextInt();
   int p=in.nextInt();
   for (int i=0;i<n;i++){
      q.add(new LinkedList<Integer>());  }
   for(int i=0;i<n;i++){
   s=in.next();
   if(s.equals("+")){
    a=in.nextInt();
    b=in.nextInt();
    q.get(a-1).add(b);
    cnt++;
    f.add(cnt);
    if(cnt>p){ x=false; }
   }
   if(s.equals("-")){
    a=in.nextInt();
    b=in.nextInt();
    if(q.get(a-1).size()==0||q.get(a-1).getLast()!=b){ x=false; }
    else{ q.get(a-1).removeLast(); cnt--; }
   }
   }
   for(int i=0;i<n;i++){
    if(q.get(i).size()!=0){ x=false; }   
   }
  if(x){
   int max=0;
   for (int i=0;i<f.size();i++){
     if(f.get(i)>max){ max=f.get(i); }
   }
   out.print(max);
  }
  else{ out.print("Error"); }
  in.close();
  out.close();
  }
}
