#include using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) typedef vector VI; typedef vector VVI; typedef vector VL; typedef vector VVL; typedef long long LL; #define all(a) (a).begin(), (a).end() #define Yes(n) cout << ((n) ? "Yes" : "No" ) << endl #define ALL(a) (a).begin(),(a).end() #define pb push_back int A[200000],q; LL f(LL x){ VL B; rep(i,q){ int m=B.size(); if(A[i]==0){B.pb(x);} if(A[i]>0){B.pb(A[i]);} if(A[i]==-1){ B[m-2]+=B[m-1];B.pop_back(); } if(A[i]==-2){ B[m-2]=max(B[m-2],B[m-1]);B.pop_back(); } if(A[i]==-3){ B[m-2]=min(B[m-2],B[m-1]);B.pop_back(); } } return B[0]; } int main() { cin>>q; LL y;cin>>y; int m=0; rep(i,q){ string s;cin>>s; if(s=="+"){A[i]=-1;} else if(s=="max"){A[i]=-2;} else if(s=="min"){A[i]=-3;} else if(s=="X"){A[i]=0;} else{A[i]=s[0]-'0';} } if(f(2*y)1){ t=(r+l)/2; if(f(t)>=y){r=t;} else{l=t;} } if(f(r)!=y){r=-1;} cout<