import java.util.*;

public class Main {
	public static void main(String[] args){
		Scanner scanner = new Scanner(System.in);
		String next;
		int op1, op2;
		Stack<Integer> stack = new Stack<Integer>();

		while(scanner.hasNext()){
			next = scanner.next();
			switch(next){
				case "+":
					op1 = stack.pop();
					op2 = stack.pop();
					stack.push(op2+op1);
					break;
				case "-":
					op1 = stack.pop();
					op2 = stack.pop();
					stack.push(op2-op1);
					break;
				case "*":
					op1 = stack.pop();
					op2 = stack.pop();
					stack.push(op2*op1);
					break;
				default :
					stack.push(Integer.parseInt(next));
			}
		}

		System.out.println(stack.pop());

	}
} import java.util.*; util.* java public class Main {
	public static void main(String[] args){
		Scanner scanner = new Scanner(System.in);
		String next;
		int op1, op2;
		Stack<Integer> stack = new Stack<Integer>();

		while(scanner.hasNext()){
			next = scanner.next();
			switch(next){
				case "+":
					op1 = stack.pop();
					op2 = stack.pop();
					stack.push(op2+op1);
					break;
				case "-":
					op1 = stack.pop();
					op2 = stack.pop();
					stack.push(op2-op1);
					break;
				case "*":
					op1 = stack.pop();
					op2 = stack.pop();
					stack.push(op2*op1);
					break;
				default :
					stack.push(Integer.parseInt(next));
			}
		}

		System.out.println(stack.pop());

	}
} Main public static void main(String[] args){
		Scanner scanner = new Scanner(System.in);
		String next;
		int op1, op2;
		Stack<Integer> stack = new Stack<Integer>();

		while(scanner.hasNext()){
			next = scanner.next();
			switch(next){
				case "+":
					op1 = stack.pop();
					op2 = stack.pop();
					stack.push(op2+op1);
					break;
				case "-":
					op1 = stack.pop();
					op2 = stack.pop();
					stack.push(op2-op1);
					break;
				case "*":
					op1 = stack.pop();
					op2 = stack.pop();
					stack.push(op2*op1);
					break;
				default :
					stack.push(Integer.parseInt(next));
			}
		}

		System.out.println(stack.pop());

	} main {
		Scanner scanner = new Scanner(System.in);
		String next;
		int op1, op2;
		Stack<Integer> stack = new Stack<Integer>();

		while(scanner.hasNext()){
			next = scanner.next();
			switch(next){
				case "+":
					op1 = stack.pop();
					op2 = stack.pop();
					stack.push(op2+op1);
					break;
				case "-":
					op1 = stack.pop();
					op2 = stack.pop();
					stack.push(op2-op1);
					break;
				case "*":
					op1 = stack.pop();
					op2 = stack.pop();
					stack.push(op2*op1);
					break;
				default :
					stack.push(Integer.parseInt(next));
			}
		}

		System.out.println(stack.pop());

	} Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) String next; next int op1 op1 op2; op2 Stack<Integer> stack = new Stack<Integer>(); stack new Stack<Integer>() while(scanner.hasNext()){
			next = scanner.next();
			switch(next){
				case "+":
					op1 = stack.pop();
					op2 = stack.pop();
					stack.push(op2+op1);
					break;
				case "-":
					op1 = stack.pop();
					op2 = stack.pop();
					stack.push(op2-op1);
					break;
				case "*":
					op1 = stack.pop();
					op2 = stack.pop();
					stack.push(op2*op1);
					break;
				default :
					stack.push(Integer.parseInt(next));
			}
		} scanner.hasNext() scanner.hasNext scanner {
			next = scanner.next();
			switch(next){
				case "+":
					op1 = stack.pop();
					op2 = stack.pop();
					stack.push(op2+op1);
					break;
				case "-":
					op1 = stack.pop();
					op2 = stack.pop();
					stack.push(op2-op1);
					break;
				case "*":
					op1 = stack.pop();
					op2 = stack.pop();
					stack.push(op2*op1);
					break;
				default :
					stack.push(Integer.parseInt(next));
			}
		} next = scanner.next() next scanner.next() scanner.next scanner switch(next){
				case "+":
					op1 = stack.pop();
					op2 = stack.pop();
					stack.push(op2+op1);
					break;
				case "-":
					op1 = stack.pop();
					op2 = stack.pop();
					stack.push(op2-op1);
					break;
				case "*":
					op1 = stack.pop();
					op2 = stack.pop();
					stack.push(op2*op1);
					break;
				default :
					stack.push(Integer.parseInt(next));
			} next case "+": "+" case "+": op1 = stack.pop() op1 stack.pop() stack.pop stack op2 = stack.pop() op2 stack.pop() stack.pop stack stack.push(op2+op1) stack.push stack op2+op1 op2 op1 break; case "-": "-" case "-": op1 = stack.pop() op1 stack.pop() stack.pop stack op2 = stack.pop() op2 stack.pop() stack.pop stack stack.push(op2-op1) stack.push stack op2-op1 op2 op1 break; case "*": "*" case "*": op1 = stack.pop() op1 stack.pop() stack.pop stack op2 = stack.pop() op2 stack.pop() stack.pop stack stack.push(op2*op1) stack.push stack op2*op1 op2 op1 break; default : default : stack.push(Integer.parseInt(next)) stack.push stack Integer.parseInt(next) Integer.parseInt Integer next System.out.println(stack.pop()) System.out.println System.out System System.out stack.pop() stack.pop stack String[] args args public class Main {
	public static void main(String[] args){
		Scanner scanner = new Scanner(System.in);
		String next;
		int op1, op2;
		Stack<Integer> stack = new Stack<Integer>();

		while(scanner.hasNext()){
			next = scanner.next();
			switch(next){
				case "+":
					op1 = stack.pop();
					op2 = stack.pop();
					stack.push(op2+op1);
					break;
				case "-":
					op1 = stack.pop();
					op2 = stack.pop();
					stack.push(op2-op1);
					break;
				case "*":
					op1 = stack.pop();
					op2 = stack.pop();
					stack.push(op2*op1);
					break;
				default :
					stack.push(Integer.parseInt(next));
			}
		}

		System.out.println(stack.pop());

	}
} public class Main {
	public static void main(String[] args){
		Scanner scanner = new Scanner(System.in);
		String next;
		int op1, op2;
		Stack<Integer> stack = new Stack<Integer>();

		while(scanner.hasNext()){
			next = scanner.next();
			switch(next){
				case "+":
					op1 = stack.pop();
					op2 = stack.pop();
					stack.push(op2+op1);
					break;
				case "-":
					op1 = stack.pop();
					op2 = stack.pop();
					stack.push(op2-op1);
					break;
				case "*":
					op1 = stack.pop();
					op2 = stack.pop();
					stack.push(op2*op1);
					break;
				default :
					stack.push(Integer.parseInt(next));
			}
		}

		System.out.println(stack.pop());

	}
} Main
import java.util.*;

public class Main {
	public static void main(String[] args){
		Scanner scanner = new Scanner(System.in);
		String next;
		int op1, op2;
		Stack<Integer> stack = new Stack<Integer>();

		while(scanner.hasNext()){
			next = scanner.next();
			switch(next){
				case "+":
					op1 = stack.pop();
					op2 = stack.pop();
					stack.push(op2+op1);
					break;
				case "-":
					op1 = stack.pop();
					op2 = stack.pop();
					stack.push(op2-op1);
					break;
				case "*":
					op1 = stack.pop();
					op2 = stack.pop();
					stack.push(op2*op1);
					break;
				default :
					stack.push(Integer.parseInt(next));
			}
		}

		System.out.println(stack.pop());

	}
}