import java.io.*;
import java.util.*;

public class Bjarki {
    public static void main(String[] args) throws Exception {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        Map<String, Integer> left = new HashMap<String, Integer>();
        Map<String, Integer> right = new HashMap<String, Integer>();
        Map<String, Integer> any = new HashMap<String, Integer>();
        Set<String> types = new HashSet<String>();
        long total = 0;
        for (int i = 0; i < n; i++) {
            String type = in.next();
            types.add(type);
            String fit = in.next();
            int cnt = in.nextInt();
            Map<String, Integer> m = left;
            if (fit.equals("left")) m = left;
            if (fit.equals("right")) m = right;
            if (fit.equals("any")) m = any;
            if (!m.containsKey(type)) m.put(type, 0);
            m.put(type, m.get(type) + cnt);
            total += cnt;
        }
        int mx = 0;
        for (String type : types) {
            int cur = 0;
            if (any.containsKey(type) && any.get(type) >= 1) cur = Math.max(cur, 1);
            if (left.containsKey(type)) cur = Math.max(cur, left.get(type));
            if (right.containsKey(type)) cur = Math.max(cur, right.get(type));
            mx += cur;
        }
        if (mx == total) {
            System.out.println("impossible");
        } else {
            System.out.printf("%d\n", mx + 1);
        }
    }
}
