import java.util.Scanner;
import java.util.Stack;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
while (sc.hasNext()) {
String line = sc.nextLine();
line = line.replaceAll("\\{", "(");
line = line.replaceAll("}", ")");
line = line.replaceAll("\\[", "(");
line = line.replaceAll("]", ")");
System.out.println(resolve(line));
}
sc.close();
}
private static int resolve(String line) {
char[] chars = line.toCharArray();
int length = chars.length;
Stack<Integer> stack = new Stack<>();
stack.push(0);
int number = 0;
char sign = '+';
for (int i = 0; i < length; i++) {
char c = chars[i];
if (c == ' ') {
continue;
}
if (Character.isDigit(c)) {
number = number * 10 + c - '0';
}
if (c == '(') {
int j = i + 1;
int count = 1;
while (count > 0) {
if (chars[j] == ')') {
count--;
}
if (chars[j] == '(') {
count++;
}
j++;
}
number = resolve(line.substring(i + 1, j - 1));
i = j - 1;
}
if (!Character.isDigit(c) || i == length - 1) {
if (sign == '+') {
stack.push(number);
} else if (sign == '-') {
stack.push(-1 * number);
} else if (sign == '*') {
stack.push(stack.pop() * number);
} else if (sign == '/') {
stack.push(stack.pop() / number);
}
sign = c;
number = 0;
}
}
int sum = 0;
while (!stack.isEmpty()) {
sum += stack.pop();
}
return sum;
}
}