Q, Y = map(int, input().split()) S = input().split() assert 1 <= Q <= 2 * 10**5 assert 0 <= Y <= 10**14 assert len(S) == Q def rev_poland(x): A = [] for s in S: if s in ('+', 'min', 'max'): a = A.pop() b = A.pop() if s == '+': A.append(a + b) if s == 'min': A.append(min(a, b)) if s == 'max': A.append(max(a, b)) else: if s == 'X': A.append(x) else: assert 0 <= int(s) <= 10**9 A.append(int(s)) return A[0] ok, ng = 10**14, -1 while ok - ng > 1: mid = (ok + ng) // 2 if rev_poland(mid) >= Y: ok = mid else: ng = mid if rev_poland(ok) == Y: print(ok) else: print(-1)