class HelloWorld {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
String s = in.nextLine();
//预处理
s = s.replaceAll("\\{", "(").replaceAll("\\}", ")")
.replaceAll("\\[", "(").replaceAll("\\]", ")")
.replaceAll("\\(\\+", "\\(0\\+").replaceAll("\\(\\-", "\\(0\\-");
if (s.charAt(0) == '-') {
s = '0' + s;
}
// 优先级
Map<Character, Integer> map = new HashMap<>();
map.put('+', 1);
map.put('-', 1);
map.put('*', 2);
map.put('/', 2);
// 使用两个栈
Stack<Character> op = new Stack<>();
Stack<Integer> num = new Stack<>();
for (int i = 0; i < s.length(); i++) {
if (Character.isDigit(s.charAt(i))) {// 操作数
int j = 0, k = i;
while (k<s.length()&&Character.isDigit(s.charAt(k))) {
int g = s.charAt(k) - '0';
j = j * 10 + g;
k++;
}
i = k - 1;
num.push(j);
} else {//运算符
// 括号单独处理
if (s.charAt(i) == '(') {
op.push(s.charAt(i));
} else if (s.charAt(i) == ')') {
while (op.peek()!='(') {
calc1(num,op);
}
op.pop();
} else {//运算符
while (!op.isEmpty() && op.peek() != '(' && map.get(op.peek()) >= map.get(s.charAt(i))) {
calc1(num, op);
}
op.push(s.charAt(i));
}
}
}
while (!op.isEmpty()) {
calc1(num,op);
}
System.out.println(num.peek());
}
static void calc1(Stack<Integer> num, Stack<Character> op) {
Integer pop2 = num.pop();
Integer pop1 = num.pop();
Character p = op.pop();
switch (p) {
case '+':
num.push(pop1 + pop2);
break;
case '-':
num.push(pop1 - pop2);
break;
case '*':
num.push(pop1 * pop2);
break;
case '/':
num.push(pop1 / pop2);
break;
}
}
}