import java.util.Scanner;
import java.util.Stack;
public class Main {
public int solution(String str) {
int answer = 0;
Stack<Integer> stack = new Stack<>();
//숫자들을 일단 스택에 넣어놔라
for(char x : str.toCharArray()) {
//숫자일 때
if(Character.isDigit(x)) stack.push(x-48);
//연산자를 만났을 때
else {
int rt = stack.pop(); //오른쪽 숫자
int lt = stack.pop(); //왼쪽 숫자
if(x=='+') stack.push(lt+rt);
else if(x=='-') stack.push(lt-rt);
else if(x=='*') stack.push(lt*rt);
else if(x=='/') stack.push(lt/rt);
}
answer = stack.get(0);
}
return answer;
}
public static void main(String[] args){
Main T = new Main();
Scanner kb = new Scanner(System.in);
String str = kb.next();
System.out.print(T.solution(str));
}
}