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

/**
 * Created by IntelliJ IDEA.
 * User: m09fpv
 * Date: 02.12.2009
 * Time: 15:43:48
 * To change this template use File | Settings | File Templates.
 */
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"));
   int n=in.nextInt();
   String s;  int r,cnt;
   cnt=0;
   int a[]=new int[100000];
   for(int i=0;i<n;i++){
     s=in.next();
    if(s.equals("declare")){ a[i]=-1; }
    else { r=in.nextInt();
           a[i]=r; }
    }
    for(int i=n-1;i>=0;i--){
      if(a[i]!=0&&a[i]!=-1){
       a[a[i]-1]=0;
      }
    }
    for(int i=0;i<n;i++){
      if(a[i]!=0){  cnt++; }
    }
    out.println(cnt);
    for(int i=0;i<n;i++){
     if(a[i]!=0){
          out.print(i+1+" "); }
    }
  in.close();
  out.close();
  }
}
