#include <iostream>
#include <stack>
using namespace std;
int priority(char op) {
if (op == '#') return 0;
if (op == '+' || op == '-') return 1;
if (op == '*' || op == '/') return 2;
else return -1;
}
int compute(int a, int b, char op) {
switch (op) {
case '+':
return a + b;
case '-':
return a - b;
case '*':
return a * b;
case '/':
return b != 0 ? a / b : 0;
default:
return 0;
}
}
int main() {
string str;
while (cin >> str) {
stack<char> op;
stack<int> num;
string tem;
char ch;
str += '#';
for (int i = 0; i < str.size(); ++i) {
ch = i > 0 ? str[i - 1] : '$';
if (str[i] >= '0' && str[i] <= '9') tem += str[i];
else {
if (str[i] == '[' || str[i] == '{') str[i] = '(';
else if (str[i] == ']' || str[i] == '}') str[i] = ')';
if (!(ch >= '0' && ch <= '9') && ch != ')' && str[i] == '-') {
tem += str[i];
continue;
}
if (!tem.empty()) {
num.push(stoi(tem));
tem.clear();
}
if (str[i] == '(') op.push(str[i]);
else if (str[i] == ')') {
while (!op.empty() && op.top() != '(') {
char c = op.top();
op.pop();
int b = num.top();
num.pop();
int a = num.top();
num.pop();
int sum = compute(a, b, c);
num.push(sum);
}
op.pop();
} else {
while (!op.empty() && priority(op.top()) >= priority(str[i])) {
char c = op.top();
op.pop();
int b = num.top();
num.pop();
int a = num.top();
num.pop();
int sum = compute(a, b, c);
num.push(sum);
}
op.push(str[i]);
}
}
}
cout << num.top() << endl;
}
return 0;
}