import java.io.*; import java.util.Stack; public class Main { public static Boolean gogo(char a,char b) { if(a=='('||b=='(') return false; else if(a=='*'||a=='/'||b=='+'||b=='-'||b==')') return true; else return false; } public static void main(String[] args) throws IOException { BufferedReader cin = new BufferedReader(new InputStreamReader(System.in)); String s; char t; int a,b; Stack<Character> p=new Stack<Character>(); Stack<Integer> d=new Stack<Integer>(); while((s=cin.readLine())!=null) //cin.ready() { for(int i=0;i<s.length()&&s.charAt(i)!='#';i++) { t=s.charAt(i); if(t=='+'||t=='-'||t=='*'||t=='/'||t=='('||t==')') { while(p.empty()!=true) { if(t==')'&&p.peek()=='(') { if(i<s.length()-1&&s.charAt(i+1)!='#') { i++; t=s.charAt(i); } p.pop(); } if(p.empty()!=true&&gogo(p.peek(),t)) { b=d.pop(); a=d.pop(); if(p.peek()=='+') { a=a+b; } else if(p.peek()=='-') { a=a-b; } else if(p.peek()=='*') { a=a*b; } else if(p.peek()=='/') { a=a/b; } d.push(a); p.pop(); } else break; } if(t!=')') p.push(t); } else { a=t-'0'; for(int j=i+1;j<s.length();j++) { if(Character.isDigit(s.charAt(j))) { a=a*10+(s.charAt(j)-'0'); i++; } else { i=j-1; break; } } d.push(a); } } while(p.empty()!=true) { b=d.pop(); a=d.pop(); if(p.peek()=='+') { a=a+b; } else if(p.peek()=='-') { a=a-b; } else if(p.peek()=='*') { a=a*b; } else if(p.peek()=='/') { a=a/b; } d.push(a); p.pop(); } System.out.println(d.peek()); p.clear(); d.clear(); } cin.close(); } } /************************************************************** Problem: 2145 User: admin Language: Java Result: Accepted Time:401 ms Memory:34764 kb ****************************************************************/