import java.util.*;
public class Main {
//20*{1+2*[-4/(8-6)+7]}+3
public static void main(String[] args) {
Scanner sc =new Scanner(System.in);
String sb = sc.nextLine();
System.out.println(getCountResult(sb));
}
private static int pos=0;
private static int getCountResult(String sb) {
//S数据进栈必须配合opt
Stack<Integer> stackTemp = new Stack<>();
Integer temp =0;
char opt='+';
//栈帧 就是happens-before opt记录了上个世界的事情啊
while (pos<sb.length()){
if('['==sb.charAt(pos)||'{'==sb.charAt(pos)||'('==sb.charAt(pos)){
pos++;
temp=getCountResult(sb);
}
//获取数字
while (pos<sb.length()&&Character.isDigit(sb.charAt(pos))){
temp=temp*10+sb.charAt(pos)-'0';
pos++;
}
//数字取完就只剩下运算符了
if (opt=='+') stackTemp.push(temp);
if (opt=='-') stackTemp.push(-temp);
if (opt=='*') stackTemp.push(stackTemp.pop()*temp);
if (opt=='/') stackTemp.push(stackTemp.pop()/temp);
temp=0;
if (pos<sb.length()&&(sb.charAt(pos)==')'||sb.charAt(pos)==']'||sb.charAt(pos)=='}')){
pos++;
break;
}else if (pos<sb.length()){
opt=sb.charAt(pos);
pos++;
}
}
int sum =0;
while (!stackTemp.isEmpty()){
sum+=stackTemp.pop();
}
return sum;
}
}