import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Scanner;
public class Main {
public static void main(String[] args){
Scanner kb = new Scanner(System.in);
int n = kb.nextInt();
HashMap<String, Integer> map = new HashMap<>();
for(int i=0; i<n; i++) {
String name = kb.next();
String status = kb.next();
if(status.equals("enter")) {
map.put(name, map.getOrDefault(name, 0)+1);
}else {
map.remove(name);
}
}
List<String> list = new ArrayList<>();
for(String x: map.keySet()) {
list.add(x);
}
Collections.sort(list, Collections.reverseOrder());
for(String x: list) {
System.out.println(x);
}
}
}