/*--------------------------------------------------------------*/
/* ACM ICPC 2009-2010, NEERC                                    */
/* Northern Subregional Contest                                 */
/* St Petersburg, October 17, 2009                              */
/*--------------------------------------------------------------*/
/* Problem B. Bureaucracy                                       */
/*                                                              */
/* Original idea         Pavel Mavrin                           */
/* Problem statement     Dmitry Paraschenko                     */
/* Testset               Dmitry Paraschenko                     */
/*--------------------------------------------------------------*/
/* Solution                                                     */
/*                                                              */
/* Author                Dmitry Paraschenko                     */
/*--------------------------------------------------------------*/
 
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;


public class bureau_dp implements Runnable {
    private static final int MAX_N = 100000;
    private Scanner in;
    private PrintWriter out;
    
    public void solve() {
        int n = in.nextInt();
        assert 1 <= n && n <= MAX_N;
        int[] link = new int[n];
        Arrays.fill(link, -1);
        for (int i = 0; i < n; i++) {
            String cmd = in.next();
            if ("cancel".equals(cmd)) {
                link[i] = in.nextInt() - 1;
                assert 0 <= link[i] && link[i] < i;
            } else {
                assert "declare".equals(cmd);
            }
        }
        boolean[] inactive = new boolean[n];
        List<Integer> answer = new ArrayList<Integer>();
        for (int i = n - 1; i >= 0; i--) {
            if (!inactive[i]) {
                answer.add(i);
                if (link[i] >= 0) {
                    inactive[link[i]] = true; 
                }
            }
        }
        Collections.reverse(answer);
        out.println(answer.size());
        for (int x : answer) {
            out.printf("%d ", x + 1);
        }
    }

    public bureau_dp(String file) {
        try {
            in = new Scanner(System.in);
            out = new PrintWriter(System.out);
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(1);
        }
    }

    public void run() {
        try {
            solve();
        } finally {
            out.close();
        }
    }

    public static void main(String[] args) {
        new Thread(new bureau_dp("bureau")).start();
    }
}
