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; for (int i = 0; i < q; i++) { if (sa[i].equals("X")) { flg = true; } } 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(sa, mid); if (val >= y) { ok = mid; } else { ng = mid; } } if (calc(sa, ok) == y) { System.out.println(ok); } else { System.out.println(-1); } } static long calc(String[] sa, long mid) { Deque que = new ArrayDeque<>(); for (int i = 0; i < sa.length; i++) { if (sa[i].equals("+")) { long v1 = Long.parseLong(que.pop()); long v2 = Long.parseLong(que.pop()); que.push(String.valueOf(v1 + v2)); } else if (sa[i].equals("min")) { long v1 = Long.parseLong(que.pop()); long v2 = Long.parseLong(que.pop()); que.push(String.valueOf(Math.min(v1, v2))); } else if (sa[i].equals("max")) { long v1 = Long.parseLong(que.pop()); long v2 = Long.parseLong(que.pop()); que.push(String.valueOf(Math.max(v1, v2))); } else if (sa[i].equals("X")) { que.push(String.valueOf(mid)); } else { que.push(String.valueOf(sa[i])); } } return Long.parseLong(que.pop()); } }