#define _CRT_SECURE_NO_WARNINGS //#define _GLIBCXX_DEBUG #include using namespace std; typedef long long ll; //#define int ll //#define endl "\n" typedef vector vi; typedef vector vvi; typedef pair pii; #define all(c) (c).begin(), (c).end() #define loop(i,a,b) for(ll i=a; i ostream & operator<<(ostream & os, vector const &); template typename enable_if<(n>=sizeof...(T))>::type _ot(ostream &, tuple const &){} template typename enable_if<(n< sizeof...(T))>::type _ot(ostream & os, tuple const & t){ os << (n==0?"":" ") << get(t); _ot(os, t); } template ostream & operator<<(ostream & os, tuple const & t){ _ot<0>(os, t); return os; } template ostream & operator<<(ostream & os, pair const & p){ return os << "(" << p.first << ", " << p.second << ") "; } template ostream & operator<<(ostream & os, vector const & v){ rep(i,v.size()) os << v[i] << (i+1==(int)v.size()?"":" "); return os; } template inline bool chmax(T & x, T const & y){ return x inline bool chmin(T & x, T const & y){ return x>y ? x=y,true : false; } #ifdef DEBUG #define dump(...) (cerr<<#__VA_ARGS__<<" = "< #include #include #include #include #include #include using namespace std; char e[1000]; typedef long long ll; typedef complex C; inline bool valid(C x){ ll t = max(abs(x.real()),abs(x.imag())); return t <= 1000000000000000LL; } class OverFlow {}; C expr(char* &p); C term(char* &p); C fact(char* &p); C num(char* &p); inline bool ispm(char c){ return c=='+' || c=='-'; } inline bool ispd(char c){ return c=='*' || c=='/'; } C num(char* &p){ C res = 0; if(isdigit(*p) || *p == 'i'){ ; }else{ throw "num begin"; } if(isdigit(*p)){ while (isdigit(*p)){ res*=10; res+=*p-'0'; if(!valid(res)) throw OverFlow(); p++; } }else{ res = C(0,1); p++; } if(*p=='\0' || *p==')' || ispm(*p) || ispd(*p)){ ; }else{ throw "num end"; } if(!valid(res)) throw OverFlow(); return res; } C fact(char* & p){ C res = 0; if(*p=='(' || isdigit(*p) || *p == 'i'){ ; }else{ throw "fact begin"; } if(*p=='('){ p++; res += expr(p); p++; }else if(isdigit(*p) || *p == 'i'){ res += num(p); } if(*p=='\0' || *p==')' || ispm(*p) || ispd(*p)){ ; }else{ cout << p-e << endl; throw "fact end"; } if(!valid(res)) throw OverFlow(); return res; } C term(char* & p){ C res; if(*p=='(' || isdigit(*p) || *p == 'i'){ res = fact(p); }else{ throw "term begin"; } while(1){ if(*p=='*'){ p++; res *= fact(p); }else if(*p=='/'){ p++; res /= fact(p); }else if(*p=='\0' || *p==')' || *p=='+' || *p=='-'){ break; }else{ throw "term end"; } if(!valid(res)) throw OverFlow(); } if(!valid(res)) throw OverFlow(); return res; } C expr(char* & p){ C res; if(*p=='(' || isdigit(*p) || *p == 'i'){ res=term(p); }else{ throw "exp begin"; } while(1){ if(*p=='+'){ p++; res += term(p); }else if(*p=='-'){ p++; res -= term(p); }else if(*p=='\0' || *p==')'){ break; }else{ throw "exp end"; } if(!valid(res)) throw OverFlow(); } return res; } signed main(){ ios_base::sync_with_stdio(0); cin.tie(0); string s; while(cin >> s){ int n = s.size(); int ans = 0; rep(i,n) s += s[i]; rep(i,n){ rep(j,n) e[j] = s[i+j]; e[n] = 0; try { char * p = e; if(*p=='+' || *p=='-') throw ""; if(*(p+n-1)=='+' || *(p+n-1)=='-') throw ""; int x = expr(p).real(); ans = max(x,ans); } catch(...){} } cout << ans << endl; } }