from collections import deque, defaultdict, Counter from bisect import bisect_left, bisect_right from itertools import permutations, combinations from functools import cmp_to_key, cache from heapq import heappop, heappush import math, sys import pypyjit pypyjit.set_param('max_unroll_recursion=-1') sys.setrecursionlimit(10**7) _int = lambda x: int(x)-1 MOD = 998244353 INF = 1<<62 Yes, No = "Yes", "No" Q, Y = map(int, input().split()) S = input().split() def calc(x): stack = [] for c in S: if c == "+": l, r = stack.pop(), stack.pop() stack.append(l+r) elif c == "min": l, r = stack.pop(), stack.pop() stack.append(min(l, r)) elif c == "max": l, r = stack.pop(), stack.pop() stack.append(max(l, r)) elif c == "X": stack.append(x) else: stack.append(int(c)) return stack[0] l, r = -1, 10**15 while r-l > 1: m = (l+r)//2 res = calc(m) if res >= Y: r = m else: l = m print(r if calc(r) == Y else -1)