#include #include #include using lint = long long; constexpr lint INF = 1LL << 60; void solve() { std::string s; std::cin >> s; lint ans = -INF; for (int q = 0; q < (int)s.length(); ++q) { std::rotate(s.begin(), s.begin() + 1, s.end()); if (!std::isdigit(s.front()) || !std::isdigit(s.back())) continue; lint acc = 0, x = 0; char prev = '+'; for (char c : s) { if (std::isdigit(c)) { x = x * 10 + (c - '0'); } else { if (prev == '+') { acc += x; } else { acc -= x; } x = 0; prev = c; } } if (prev == '+') { acc += x; } else { acc -= x; } ans = std::max(ans, acc); } std::cout << ans << std::endl; } int main() { std::cin.tie(nullptr); std::ios::sync_with_stdio(false); solve(); return 0; }