#include using namespace std; #define int long long typedef pairpint; typedef vectorvint; typedef vectorvpint; #define pb push_back #define mp make_pair #define fi first #define se second #define all(v) (v).begin(),(v).end() #define rep(i,n) for(int i=0;i<(n);i++) #define reps(i,f,n) for(int i=(f);i<(n);i++) #define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++) templatevoid chmin(T &t,U f){if(t>f)t=f;} templatevoid chmax(T &t,U f){if(t>n; rep(i,n){ char c;cin>>c; if(isdigit(c))a.pb(c-'0'); else if(c=='+')x++; else y++; } sort(a.rbegin(),a.rend()); int ma=0; rep(i,a.size()-x-y)ma=ma*10+a[i]; reps(i,a.size()-x-y,a.size()-y)ma+=a[i]; reps(i,a.size()-y,a.size())ma-=a[i]; int mi=0; if(y){ rep(i,a.size()-x-y)mi=mi*10-a[i]; x++;y--; reps(i,a.size()-x-y,a.size()-x)mi-=a[i]; reps(i,a.size()-x,a.size())mi+=a[i]; } else{ vint vec(x+1,0); reverse(all(a)); rep(i,a.size())vec[i%(x+1)]=vec[i%(x+1)]*10+a[i]; rep(i,vec.size())mi+=vec[i]; } cout<