import java.util.*;
import java.io.*;

class ship implements Runnable{
     public void run(){
       try{
           Scanner in = new Scanner(new File("ship.in"));
           PrintWriter out = new PrintWriter(new File("ship.out"));

           int n = in.nextInt();
           int k = in.nextInt();
           int p = in.nextInt();
           boolean res = true;
           int max = 0;

          ArrayList<LinkedList<Integer>> l = new ArrayList<LinkedList<Integer>>();
          for(int i = 0; i < k ;i++)
             l.add(new LinkedList<Integer>());
           int cnt=0;
           for(int i = 0; i < n; i++){
               char c = (in.next()).charAt(0);
               int j = in.nextInt();
               int s = in.nextInt();
               if(c=='+'){
                   l.get(j%k).addLast(s);
                   cnt++;
                   if(cnt > max) max=cnt;
                   if(cnt > p){
                      res = false;
                       out.println("cnt=  "+cnt);
                      break;
                   }
               }
               else{
                 cnt--;
                 if(l.get(j%k).getLast()!=s){
                     res = false;
                     break;
                 }
                 l.get(j%k).removeLast();
               }
           }
           if(cnt!=0){
             res = false;
           }
           if(res)
             out.println(max);
           else
             out.println("Error");

           in.close();
           out.close();
       }  catch(Exception e){
               e.printStackTrace();
               System.exit(1);
          }
     }
     public static void main(String[] args) {
       new Thread(new ship()).start();
    }
}
