#include using namespace std; using ll = long long; vector S; ll N,Y,y,z; ll f(ll x){ stack P; for(auto s:S){ if(s=="X")P.push(x); else if(isdigit(s[0]))P.push(stoll(s)); else{ y=P.top(); P.pop(); z=P.top(); P.pop(); P.push(s=="+"?y+z:s=="min"?min(y,z):max(y,z)); } } return P.top(); } int main() { cin>>N>>Y; S.resize(N); for(auto &s:S)cin>>s; ll L=-1,R=Y+1; while(R-L>1)(f((R+L)/2)>=Y?R:L)=(R+L)/2; cout<<(f(R)==Y?R:-1)<