/**
 * Created by IntelliJ IDEA.
 * User: m09aaa
 * Date: 02.12.2009
 * Time: 16:24:15
 * To change this template use File | Settings | File Templates.
 */
import java.util.*;
import java.io.*;

public class Bureau {
     public static void main(String [] args) throws Exception{
        Scanner in=new Scanner(new File("bureau.in"));
        PrintWriter out=new PrintWriter(new File("bureau.out"));
        LinkedList <String> rule=new LinkedList<String>();
         int n=in.nextInt();
         int kol=n;
         boolean [] actual=new boolean [n+1];
         for (int j=0; j<=n; j++)
         {
             actual[j]=true;
         }
         for (int i=0; i<=n; i++)
         {
             rule.addLast(in.nextLine());
         }
         for (int i=n; i>0; i--)
         {
             if (actual[i]&&rule.get(i).substring(0,6).equals("cancel"))
             {
                  int f=0;
                 for (int k=7; k<rule.get(i).length(); k++)
                 {
                     f=f*10+(rule.get(i).charAt(k)-'0');
                     System.out.println(rule.get(i).charAt(k)-'0');
                 }
                 actual[f]=false;
                 kol--;
             }
         }
         out.println(kol);
         for (int i=1; i<=n; i++)
         {
            if (actual[i]) {out.println(i);}
         }
          out.close();
     }
}
