#include #include #include #include int solve(std::string s) { std::queue q; int num = 0; for (int i = 0; i < s.length(); i++) { if (!isdigit(s[i])) { if (i == 0 || i == s.length() - 1 || !isdigit(s[i + 1])) return 0; q.push(std::to_string(num)); q.push(std::to_string(s[i])); num = 0; } else num = num * 10 + (s[i] - '0'); } q.push(std::to_string(num)); num = std::stoi(q.front());q.pop(); while (q.size()) { std::string d = q.front();q.pop(); if (d == "43") num += std::stoi(q.front()); else num -= std::stoi(q.front()); q.pop(); } return num; } int main() { std::string str; std::cin >> str; int max = 0; for (int i = 0; i < str.length(); i++) { max = std::max(solve(str), max); char s = str.back(); str.erase(str.end() - 1); str.insert(str.begin(), s); } std::cout << max << std::endl; return 0; }