Q,Y = map(int,input().split()) S = input().split() def is_ok(x): if x < 0: return False stack = [] for s in S: if s in ('+','min','max'): a = stack.pop() b = stack.pop() if s == '+': c = a+b elif s == 'min': c = min(a,b) else: c = max(a,b) stack.append(c) elif s == 'X': stack.append(x) else: stack.append(int(s)) v = stack.pop() return v >= Y, v ng = -1 ok = 10**24 while ok - ng > 1: mid = (ok+ng)//2 if is_ok(mid)[0]: ok = mid else: ng = mid v = is_ok(ok)[1] print(ok if v == Y else -1)