import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.ArrayDeque; import java.util.Deque; public class Main { public static void main(String[] args) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String[] sa = br.readLine().split(" "); int q = Integer.parseInt(sa[0]); long y = Long.parseLong(sa[1]); sa = br.readLine().split(" "); br.close(); boolean flg = false; long[] la = new long[q]; for (int i = 0; i < q; i++) { if (sa[i].equals("+")) { la[i] = -1; } else if (sa[i].equals("min")) { la[i] = -2; } else if (sa[i].equals("max")) { la[i] = -3; } else if (sa[i].equals("X")) { la[i] = -4; flg = true; } else { la[i] = Long.parseLong(sa[i]); } } if (!flg) { System.out.println(-1); return; } long ok = 100000000000000L; long ng = -1; while (Math.abs(ok - ng) > 1) { long mid = (ok + ng) / 2; long val = calc(la, mid); if (val >= y) { ok = mid; } else { ng = mid; } } if (calc(la, ok) == y) { System.out.println(ok); } else { System.out.println(-1); } } static long calc(long[] la, long mid) { Deque que = new ArrayDeque<>(); for (int i = 0; i < la.length; i++) { if (la[i] == -1) { long v1 = que.pop(); long v2 = que.pop(); que.push(v1 + v2); } else if (la[i] == -2) { long v1 = que.pop(); long v2 = que.pop(); que.push(Math.min(v1, v2)); } else if (la[i] == -3) { long v1 = que.pop(); long v2 = que.pop(); que.push(Math.max(v1, v2)); } else if (la[i] == -4) { que.push(mid); } else { que.push(la[i]); } } return que.pop(); } }