import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.PrintWriter;
import java.io.StreamTokenizer;
import java.util.LinkedList;

public class Main {
	public static void main(String args[]) throws Exception {
		StreamTokenizer s = new StreamTokenizer(new BufferedReader(
				new FileReader("bureau.in")));
		PrintWriter out = new PrintWriter(new File("bureau.out"));
		s.nextToken();
		int n = (int) s.nval;
		int[] laws = new int[n];
		for (int i = 0; i < n; i++) {
			s.nextToken();
			if (s.sval.equals("declare")) {
				laws[i] = -1;
			} else {
				s.nextToken();
				laws[i] = (int) s.nval;
			}
		}
		LinkedList<Integer> actual = new LinkedList<Integer>();
		for (int i = n - 1; i > -1; i--) {
			if (laws[i] != 0) {
				actual.add(i + 1);
			}
			if (laws[i] > 0) {
				laws[laws[i] - 1] = 0;
			}
		}
		int a =actual.size(); 
		out.println(a);
		for (int i = 0; i < a; i++) {
			out.print(actual.pollLast() + " ");
		}
		out.println();
		out.close();
	}
}
