#include #include using namespace std; int calc(string s){ if(s.empty()) return 0; size_t p; int x = stoi(s,&p); return x + calc(s.substr(p)); } int main(){ int ans = -1e9; string s; cin >> s; for(int i = 0;i < s.size();i++){ if(isdigit(s[0]) && isdigit(s[s.size() - 1])) ans = max(ans,calc(s)); s = s.substr(1) + s.front(); } cout << ans << endl; }