import java.util.Scanner;
import java.util.Stack;
class Main {
   public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		String[] str = scan.nextLine().split("\\s");
		
		Stack<Integer> stack = new Stack<Integer>();
		int x = 0;
		int y = 0;
		int tmp = 0;
		
		for(int i = 0; i < str.length; i++){
			if(str[i].equals("+")){
				x = stack.pop();
				y = stack.pop();
				stack.add(y + x);
			}else if(str[i].equals("-")){
				x = stack.pop();
				y = stack.pop();
				stack.add(y - x);
			}else if(str[i].equals("*")){
				x = stack.pop();
				y = stack.pop();
				stack.add(y * x);
			}else if(str[i].equals("/")){
				x = stack.pop();
				y = stack.pop();
				stack.add(y / x);
			}else{
				stack.push(Integer.parseInt(str[i]));
			}
		}
		
		System.out.println(stack.pop());
	}
} import java.util.Scanner; Scanner java.util import java.util.Stack; Stack java.util class Main {
   public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		String[] str = scan.nextLine().split("\\s");
		
		Stack<Integer> stack = new Stack<Integer>();
		int x = 0;
		int y = 0;
		int tmp = 0;
		
		for(int i = 0; i < str.length; i++){
			if(str[i].equals("+")){
				x = stack.pop();
				y = stack.pop();
				stack.add(y + x);
			}else if(str[i].equals("-")){
				x = stack.pop();
				y = stack.pop();
				stack.add(y - x);
			}else if(str[i].equals("*")){
				x = stack.pop();
				y = stack.pop();
				stack.add(y * x);
			}else if(str[i].equals("/")){
				x = stack.pop();
				y = stack.pop();
				stack.add(y / x);
			}else{
				stack.push(Integer.parseInt(str[i]));
			}
		}
		
		System.out.println(stack.pop());
	}
} Main public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		String[] str = scan.nextLine().split("\\s");
		
		Stack<Integer> stack = new Stack<Integer>();
		int x = 0;
		int y = 0;
		int tmp = 0;
		
		for(int i = 0; i < str.length; i++){
			if(str[i].equals("+")){
				x = stack.pop();
				y = stack.pop();
				stack.add(y + x);
			}else if(str[i].equals("-")){
				x = stack.pop();
				y = stack.pop();
				stack.add(y - x);
			}else if(str[i].equals("*")){
				x = stack.pop();
				y = stack.pop();
				stack.add(y * x);
			}else if(str[i].equals("/")){
				x = stack.pop();
				y = stack.pop();
				stack.add(y / x);
			}else{
				stack.push(Integer.parseInt(str[i]));
			}
		}
		
		System.out.println(stack.pop());
	} main {
		Scanner scan = new Scanner(System.in);
		String[] str = scan.nextLine().split("\\s");
		
		Stack<Integer> stack = new Stack<Integer>();
		int x = 0;
		int y = 0;
		int tmp = 0;
		
		for(int i = 0; i < str.length; i++){
			if(str[i].equals("+")){
				x = stack.pop();
				y = stack.pop();
				stack.add(y + x);
			}else if(str[i].equals("-")){
				x = stack.pop();
				y = stack.pop();
				stack.add(y - x);
			}else if(str[i].equals("*")){
				x = stack.pop();
				y = stack.pop();
				stack.add(y * x);
			}else if(str[i].equals("/")){
				x = stack.pop();
				y = stack.pop();
				stack.add(y / x);
			}else{
				stack.push(Integer.parseInt(str[i]));
			}
		}
		
		System.out.println(stack.pop());
	} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) String[] str = scan.nextLine().split("\\s"); str scan.nextLine().split("\\s") scan.nextLine().split scan.nextLine() scan.nextLine scan "\\s" Stack<Integer> stack = new Stack<Integer>(); stack new Stack<Integer>() int x = 0; x 0 int y = 0; y 0 int tmp = 0; tmp 0 for(int i = 0; i < str.length; i++){
			if(str[i].equals("+")){
				x = stack.pop();
				y = stack.pop();
				stack.add(y + x);
			}else if(str[i].equals("-")){
				x = stack.pop();
				y = stack.pop();
				stack.add(y - x);
			}else if(str[i].equals("*")){
				x = stack.pop();
				y = stack.pop();
				stack.add(y * x);
			}else if(str[i].equals("/")){
				x = stack.pop();
				y = stack.pop();
				stack.add(y / x);
			}else{
				stack.push(Integer.parseInt(str[i]));
			}
		} int i = 0; int i = 0; i 0 i < str.length i str.length str str.length i++ i++ i {
			if(str[i].equals("+")){
				x = stack.pop();
				y = stack.pop();
				stack.add(y + x);
			}else if(str[i].equals("-")){
				x = stack.pop();
				y = stack.pop();
				stack.add(y - x);
			}else if(str[i].equals("*")){
				x = stack.pop();
				y = stack.pop();
				stack.add(y * x);
			}else if(str[i].equals("/")){
				x = stack.pop();
				y = stack.pop();
				stack.add(y / x);
			}else{
				stack.push(Integer.parseInt(str[i]));
			}
		} {
			if(str[i].equals("+")){
				x = stack.pop();
				y = stack.pop();
				stack.add(y + x);
			}else if(str[i].equals("-")){
				x = stack.pop();
				y = stack.pop();
				stack.add(y - x);
			}else if(str[i].equals("*")){
				x = stack.pop();
				y = stack.pop();
				stack.add(y * x);
			}else if(str[i].equals("/")){
				x = stack.pop();
				y = stack.pop();
				stack.add(y / x);
			}else{
				stack.push(Integer.parseInt(str[i]));
			}
		} if(str[i].equals("+")){
				x = stack.pop();
				y = stack.pop();
				stack.add(y + x);
			}else if(str[i].equals("-")){
				x = stack.pop();
				y = stack.pop();
				stack.add(y - x);
			}else if(str[i].equals("*")){
				x = stack.pop();
				y = stack.pop();
				stack.add(y * x);
			}else if(str[i].equals("/")){
				x = stack.pop();
				y = stack.pop();
				stack.add(y / x);
			}else{
				stack.push(Integer.parseInt(str[i]));
			} str[i].equals("+") str[i].equals str[i] str i "+" {
				x = stack.pop();
				y = stack.pop();
				stack.add(y + x);
			} x = stack.pop() x stack.pop() stack.pop stack y = stack.pop() y stack.pop() stack.pop stack stack.add(y + x) stack.add stack y + x y x if(str[i].equals("-")){
				x = stack.pop();
				y = stack.pop();
				stack.add(y - x);
			}else if(str[i].equals("*")){
				x = stack.pop();
				y = stack.pop();
				stack.add(y * x);
			}else if(str[i].equals("/")){
				x = stack.pop();
				y = stack.pop();
				stack.add(y / x);
			}else{
				stack.push(Integer.parseInt(str[i]));
			} str[i].equals("-") str[i].equals str[i] str i "-" {
				x = stack.pop();
				y = stack.pop();
				stack.add(y - x);
			} x = stack.pop() x stack.pop() stack.pop stack y = stack.pop() y stack.pop() stack.pop stack stack.add(y - x) stack.add stack y - x y x if(str[i].equals("*")){
				x = stack.pop();
				y = stack.pop();
				stack.add(y * x);
			}else if(str[i].equals("/")){
				x = stack.pop();
				y = stack.pop();
				stack.add(y / x);
			}else{
				stack.push(Integer.parseInt(str[i]));
			} str[i].equals("*") str[i].equals str[i] str i "*" {
				x = stack.pop();
				y = stack.pop();
				stack.add(y * x);
			} x = stack.pop() x stack.pop() stack.pop stack y = stack.pop() y stack.pop() stack.pop stack stack.add(y * x) stack.add stack y * x y x if(str[i].equals("/")){
				x = stack.pop();
				y = stack.pop();
				stack.add(y / x);
			}else{
				stack.push(Integer.parseInt(str[i]));
			} str[i].equals("/") str[i].equals str[i] str i "/" {
				x = stack.pop();
				y = stack.pop();
				stack.add(y / x);
			} x = stack.pop() x stack.pop() stack.pop stack y = stack.pop() y stack.pop() stack.pop stack stack.add(y / x) stack.add stack y / x y x {
				stack.push(Integer.parseInt(str[i]));
			} stack.push(Integer.parseInt(str[i])) stack.push stack Integer.parseInt(str[i]) Integer.parseInt Integer str[i] str i System.out.println(stack.pop()) System.out.println System.out System System.out stack.pop() stack.pop stack String[] args args
import java.util.Scanner;
import java.util.Stack;
class Main {
   public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		String[] str = scan.nextLine().split("\\s");
		
		Stack<Integer> stack = new Stack<Integer>();
		int x = 0;
		int y = 0;
		int tmp = 0;
		
		for(int i = 0; i < str.length; i++){
			if(str[i].equals("+")){
				x = stack.pop();
				y = stack.pop();
				stack.add(y + x);
			}else if(str[i].equals("-")){
				x = stack.pop();
				y = stack.pop();
				stack.add(y - x);
			}else if(str[i].equals("*")){
				x = stack.pop();
				y = stack.pop();
				stack.add(y * x);
			}else if(str[i].equals("/")){
				x = stack.pop();
				y = stack.pop();
				stack.add(y / x);
			}else{
				stack.push(Integer.parseInt(str[i]));
			}
		}
		
		System.out.println(stack.pop());
	}
}