#include<iostream>
#include<cstring>
#include<cmath>
#include<stack>
using namespace std;
int v[50000];
stack<int> a;
stack<char> b;
void jisuan(int op) {
int c = a.top();
a.pop();
int d = a.top();
a.pop();
if (op == '+') {
a.push(c + d);
}
if (op == '-') {
a.push(c - d);
}
if (op == '*') {
a.push(c * d);
}
if (op == '/') {
a.push(c / d);
}
if (op == '^') {
a.push(pow(c, d));
}
return;
}
int main() {
v['+'] = 1;
v['-'] = 1;
v['*'] = 2;
v['/'] = 2;
v['^'] = 3;
string s;
cin >> s;
string d = "";
for (int i = 0; i < s.size(); i++) {
if (s[i] >= '0' && s[i] <= '9') {
a.push(s[i] - '0');
} else {
if (s[i] == '(') {
b.push('(');
}
if (s[i] == ')') {
while (1) {
if (b.top() == ')') {
b.pop();
break;
}
jisuan(b.top());
}
}
if (s[i] != '(' && s[i] != ')') {
while (1) {
if (v[b.top()] < v[s[i]]) {
break;
}
jisuan(b.top());
}
b.push(s[i]);
}
}
}
while (!b.empty()) {
if (b.top() != '(' && b.top() != ')') {
jisuan(b.top());
b.pop();
}
}
cout << a.top();
return 0;
}