from collections import deque from operator import __add__ def calc(X): A=deque() for op in S: A.append(op) if op[0] in "_m": A.append(str(eval(A.pop()+"("+A.pop()+","+A.pop()+")"))) return int(A[0]) Q,Y=map(int,input().split()) S=input().split() for i in range(Q): if S[i]=="+": S[i]="__add__" ok=1<<60 ng=-1 while ok-ng>1: mid=(ok+ng)//2 if calc(mid)>=Y: ok=mid else: ng=mid print(ok if calc(ok)==Y else -1)