#include using namespace std; char readchar() { static char buf[1 << 15], *ptr = buf, *end = buf; if (ptr == end) ptr = buf, end = buf + fread(buf, 1, 1 << 15, stdin); return *ptr++; } void writechar(char c = 0) { static char buf[1 << 15], *ptr = buf; if (ptr == end(buf) or c == 0) fwrite(buf, 1, ptr - buf, stdout), ptr = buf; *ptr++ = c; } template Z getint() { char c = readchar(); bool neg = c == '-'; Z res = neg ? 0 : c - '0'; while (isdigit(c = readchar())) res = res * 10 + (c - '0'); return neg ? -res : res; } template void putint(Z a, char delim = '\n') { if (a < 0) writechar('-'), a = -a; int d[40], i = 0; do d[i++] = a % 10; while (a /= 10); while (i--) writechar('0' + d[i]); writechar(delim); } string getstring(char delim = '\n') { string res; for (char c; (c = readchar()) != delim; ) res += c; return res; } void putstring(string s, char delim = '\n') { for (char c : s) writechar(c); writechar(delim); } __int128_t digits(auto& i) { __int128_t res = 0; while (isdigit(*i)) res = 10 * res + *i++ - '0'; return res; } __int128_t expr(auto& i); __int128_t num(auto& i) { switch (*i) { case '+': return num(++i); case '-': return -num(++i); case '(': { __int128_t res = expr(++i); return ++i, res; } default: return digits(i); } } __int128_t term(auto& i) { __int128_t res = num(i); while (true) switch (*i) { case '*': res *= num(++i); break; case '/': res /= num(++i); break; default: return res; } } __int128_t expr(auto& i) { __int128_t res = term(i); while (true) switch (*i) { case '+': res += term(++i); break; case '-': res -= term(++i); break; default: return res; } } int main() { string s = getstring(' '); s += getstring(); auto it = begin(s); putint(expr(it)); writechar(); }