import java.util.*;
 
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String line = sc.nextLine();
		String[] s = line.split(" ");

		Deque<Integer> stack = new ArrayDeque<>();
		for(String op : s){
			if(isNumber(op)){
				stack.addLast(Integer.parseInt(op));
			}else{
				int b = stack.removeLast();
				int a = stack.removeLast();
				int c = 0;
				if(op.equals("+")){
					c = a + b;
				}else if(op.equals("-")){
					c = a - b;
				}else if(op.equals("*")){
					c = a * b;
				}
				stack.addLast(c);
			}	
		}
		System.out.println(stack.removeLast());
	}
	public static boolean isNumber(String num) {
    try {
        Integer.parseInt(num);
        return true;
        } catch (NumberFormatException e) {
        return false;
    }
}
} import java.util.*; util.* java public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String line = sc.nextLine();
		String[] s = line.split(" ");

		Deque<Integer> stack = new ArrayDeque<>();
		for(String op : s){
			if(isNumber(op)){
				stack.addLast(Integer.parseInt(op));
			}else{
				int b = stack.removeLast();
				int a = stack.removeLast();
				int c = 0;
				if(op.equals("+")){
					c = a + b;
				}else if(op.equals("-")){
					c = a - b;
				}else if(op.equals("*")){
					c = a * b;
				}
				stack.addLast(c);
			}	
		}
		System.out.println(stack.removeLast());
	}
	public static boolean isNumber(String num) {
    try {
        Integer.parseInt(num);
        return true;
        } catch (NumberFormatException e) {
        return false;
    }
}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String line = sc.nextLine();
		String[] s = line.split(" ");

		Deque<Integer> stack = new ArrayDeque<>();
		for(String op : s){
			if(isNumber(op)){
				stack.addLast(Integer.parseInt(op));
			}else{
				int b = stack.removeLast();
				int a = stack.removeLast();
				int c = 0;
				if(op.equals("+")){
					c = a + b;
				}else if(op.equals("-")){
					c = a - b;
				}else if(op.equals("*")){
					c = a * b;
				}
				stack.addLast(c);
			}	
		}
		System.out.println(stack.removeLast());
	} main {
		Scanner sc = new Scanner(System.in);
		String line = sc.nextLine();
		String[] s = line.split(" ");

		Deque<Integer> stack = new ArrayDeque<>();
		for(String op : s){
			if(isNumber(op)){
				stack.addLast(Integer.parseInt(op));
			}else{
				int b = stack.removeLast();
				int a = stack.removeLast();
				int c = 0;
				if(op.equals("+")){
					c = a + b;
				}else if(op.equals("-")){
					c = a - b;
				}else if(op.equals("*")){
					c = a * b;
				}
				stack.addLast(c);
			}	
		}
		System.out.println(stack.removeLast());
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String line = sc.nextLine(); line sc.nextLine() sc.nextLine sc String[] s = line.split(" "); s line.split(" ") line.split line " " Deque<Integer> stack = new ArrayDeque<>(); stack new ArrayDeque<>() for(String op : s){
			if(isNumber(op)){
				stack.addLast(Integer.parseInt(op));
			}else{
				int b = stack.removeLast();
				int a = stack.removeLast();
				int c = 0;
				if(op.equals("+")){
					c = a + b;
				}else if(op.equals("-")){
					c = a - b;
				}else if(op.equals("*")){
					c = a * b;
				}
				stack.addLast(c);
			}	
		} String op s {
			if(isNumber(op)){
				stack.addLast(Integer.parseInt(op));
			}else{
				int b = stack.removeLast();
				int a = stack.removeLast();
				int c = 0;
				if(op.equals("+")){
					c = a + b;
				}else if(op.equals("-")){
					c = a - b;
				}else if(op.equals("*")){
					c = a * b;
				}
				stack.addLast(c);
			}	
		} {
			if(isNumber(op)){
				stack.addLast(Integer.parseInt(op));
			}else{
				int b = stack.removeLast();
				int a = stack.removeLast();
				int c = 0;
				if(op.equals("+")){
					c = a + b;
				}else if(op.equals("-")){
					c = a - b;
				}else if(op.equals("*")){
					c = a * b;
				}
				stack.addLast(c);
			}	
		} if(isNumber(op)){
				stack.addLast(Integer.parseInt(op));
			}else{
				int b = stack.removeLast();
				int a = stack.removeLast();
				int c = 0;
				if(op.equals("+")){
					c = a + b;
				}else if(op.equals("-")){
					c = a - b;
				}else if(op.equals("*")){
					c = a * b;
				}
				stack.addLast(c);
			} isNumber(op) isNumber op {
				stack.addLast(Integer.parseInt(op));
			} stack.addLast(Integer.parseInt(op)) stack.addLast stack Integer.parseInt(op) Integer.parseInt Integer op {
				int b = stack.removeLast();
				int a = stack.removeLast();
				int c = 0;
				if(op.equals("+")){
					c = a + b;
				}else if(op.equals("-")){
					c = a - b;
				}else if(op.equals("*")){
					c = a * b;
				}
				stack.addLast(c);
			} int b = stack.removeLast(); b stack.removeLast() stack.removeLast stack int a = stack.removeLast(); a stack.removeLast() stack.removeLast stack int c = 0; c 0 if(op.equals("+")){
					c = a + b;
				}else if(op.equals("-")){
					c = a - b;
				}else if(op.equals("*")){
					c = a * b;
				} op.equals("+") op.equals op "+" {
					c = a + b;
				} c = a + b c a + b a b if(op.equals("-")){
					c = a - b;
				}else if(op.equals("*")){
					c = a * b;
				} op.equals("-") op.equals op "-" {
					c = a - b;
				} c = a - b c a - b a b if(op.equals("*")){
					c = a * b;
				} op.equals("*") op.equals op "*" {
					c = a * b;
				} c = a * b c a * b a b stack.addLast(c) stack.addLast stack c System.out.println(stack.removeLast()) System.out.println System.out System System.out stack.removeLast() stack.removeLast stack String[] args args public static boolean isNumber(String num) {
    try {
        Integer.parseInt(num);
        return true;
        } catch (NumberFormatException e) {
        return false;
    }
} isNumber {
    try {
        Integer.parseInt(num);
        return true;
        } catch (NumberFormatException e) {
        return false;
    }
} try {
        Integer.parseInt(num);
        return true;
        } catch (NumberFormatException e) {
        return false;
    } catch (NumberFormatException e) {
        return false;
    } NumberFormatException e {
        return false;
    } return false; false {
        Integer.parseInt(num);
        return true;
        } Integer.parseInt(num) Integer.parseInt Integer num return true; true String num num public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String line = sc.nextLine();
		String[] s = line.split(" ");

		Deque<Integer> stack = new ArrayDeque<>();
		for(String op : s){
			if(isNumber(op)){
				stack.addLast(Integer.parseInt(op));
			}else{
				int b = stack.removeLast();
				int a = stack.removeLast();
				int c = 0;
				if(op.equals("+")){
					c = a + b;
				}else if(op.equals("-")){
					c = a - b;
				}else if(op.equals("*")){
					c = a * b;
				}
				stack.addLast(c);
			}	
		}
		System.out.println(stack.removeLast());
	}
	public static boolean isNumber(String num) {
    try {
        Integer.parseInt(num);
        return true;
        } catch (NumberFormatException e) {
        return false;
    }
}
} public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String line = sc.nextLine();
		String[] s = line.split(" ");

		Deque<Integer> stack = new ArrayDeque<>();
		for(String op : s){
			if(isNumber(op)){
				stack.addLast(Integer.parseInt(op));
			}else{
				int b = stack.removeLast();
				int a = stack.removeLast();
				int c = 0;
				if(op.equals("+")){
					c = a + b;
				}else if(op.equals("-")){
					c = a - b;
				}else if(op.equals("*")){
					c = a * b;
				}
				stack.addLast(c);
			}	
		}
		System.out.println(stack.removeLast());
	}
	public static boolean isNumber(String num) {
    try {
        Integer.parseInt(num);
        return true;
        } catch (NumberFormatException e) {
        return false;
    }
}
} Main
import java.util.*;
 
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String line = sc.nextLine();
		String[] s = line.split(" ");

		Deque<Integer> stack = new ArrayDeque<>();
		for(String op : s){
			if(isNumber(op)){
				stack.addLast(Integer.parseInt(op));
			}else{
				int b = stack.removeLast();
				int a = stack.removeLast();
				int c = 0;
				if(op.equals("+")){
					c = a + b;
				}else if(op.equals("-")){
					c = a - b;
				}else if(op.equals("*")){
					c = a * b;
				}
				stack.addLast(c);
			}	
		}
		System.out.println(stack.removeLast());
	}
	public static boolean isNumber(String num) {
    try {
        Integer.parseInt(num);
        return true;
        } catch (NumberFormatException e) {
        return false;
    }
}
}