import java.util.Scanner;
import java.util.Arrays;
import java.util.Deque;
import java.util.ArrayDeque;

class Main{
	public static void main(String[] args)throws Exception{
		Scanner scanner = new Scanner(System.in);
		Deque<Integer> stack = new ArrayDeque<>();
		String[] line = scanner.nextLine().split(" ");
		int a,b;

		for(int i = 0; i < line.length; i++){
			switch(line[i]){
				case "+":
					a = stack.pollLast();
					b = stack.pollLast();
					stack.offer(b + a);
					break;

				case "-":
					a = stack.pollLast();
					b = stack.pollLast();
					stack.offer(b - a);
					break;

				case "*":
					a = stack.pollLast();
					b = stack.pollLast();
					stack.offer(b * a);
					break;

				default :
					stack.offer(Integer.parseInt(line[i]));
					break;
			}
		}

		System.out.println(stack.poll());
	}
} import java.util.Scanner; Scanner java.util import java.util.Arrays; Arrays java.util import java.util.Deque; Deque java.util import java.util.ArrayDeque; ArrayDeque java.util class Main{
	public static void main(String[] args)throws Exception{
		Scanner scanner = new Scanner(System.in);
		Deque<Integer> stack = new ArrayDeque<>();
		String[] line = scanner.nextLine().split(" ");
		int a,b;

		for(int i = 0; i < line.length; i++){
			switch(line[i]){
				case "+":
					a = stack.pollLast();
					b = stack.pollLast();
					stack.offer(b + a);
					break;

				case "-":
					a = stack.pollLast();
					b = stack.pollLast();
					stack.offer(b - a);
					break;

				case "*":
					a = stack.pollLast();
					b = stack.pollLast();
					stack.offer(b * a);
					break;

				default :
					stack.offer(Integer.parseInt(line[i]));
					break;
			}
		}

		System.out.println(stack.poll());
	}
} Main public static void main(String[] args)throws Exception{
		Scanner scanner = new Scanner(System.in);
		Deque<Integer> stack = new ArrayDeque<>();
		String[] line = scanner.nextLine().split(" ");
		int a,b;

		for(int i = 0; i < line.length; i++){
			switch(line[i]){
				case "+":
					a = stack.pollLast();
					b = stack.pollLast();
					stack.offer(b + a);
					break;

				case "-":
					a = stack.pollLast();
					b = stack.pollLast();
					stack.offer(b - a);
					break;

				case "*":
					a = stack.pollLast();
					b = stack.pollLast();
					stack.offer(b * a);
					break;

				default :
					stack.offer(Integer.parseInt(line[i]));
					break;
			}
		}

		System.out.println(stack.poll());
	} main {
		Scanner scanner = new Scanner(System.in);
		Deque<Integer> stack = new ArrayDeque<>();
		String[] line = scanner.nextLine().split(" ");
		int a,b;

		for(int i = 0; i < line.length; i++){
			switch(line[i]){
				case "+":
					a = stack.pollLast();
					b = stack.pollLast();
					stack.offer(b + a);
					break;

				case "-":
					a = stack.pollLast();
					b = stack.pollLast();
					stack.offer(b - a);
					break;

				case "*":
					a = stack.pollLast();
					b = stack.pollLast();
					stack.offer(b * a);
					break;

				default :
					stack.offer(Integer.parseInt(line[i]));
					break;
			}
		}

		System.out.println(stack.poll());
	} Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) Deque<Integer> stack = new ArrayDeque<>(); stack new ArrayDeque<>() String[] line = scanner.nextLine().split(" "); line scanner.nextLine().split(" ") scanner.nextLine().split scanner.nextLine() scanner.nextLine scanner " " int a a b; b for(int i = 0; i < line.length; i++){
			switch(line[i]){
				case "+":
					a = stack.pollLast();
					b = stack.pollLast();
					stack.offer(b + a);
					break;

				case "-":
					a = stack.pollLast();
					b = stack.pollLast();
					stack.offer(b - a);
					break;

				case "*":
					a = stack.pollLast();
					b = stack.pollLast();
					stack.offer(b * a);
					break;

				default :
					stack.offer(Integer.parseInt(line[i]));
					break;
			}
		} int i = 0; int i = 0; i 0 i < line.length i line.length line line.length i++ i++ i {
			switch(line[i]){
				case "+":
					a = stack.pollLast();
					b = stack.pollLast();
					stack.offer(b + a);
					break;

				case "-":
					a = stack.pollLast();
					b = stack.pollLast();
					stack.offer(b - a);
					break;

				case "*":
					a = stack.pollLast();
					b = stack.pollLast();
					stack.offer(b * a);
					break;

				default :
					stack.offer(Integer.parseInt(line[i]));
					break;
			}
		} {
			switch(line[i]){
				case "+":
					a = stack.pollLast();
					b = stack.pollLast();
					stack.offer(b + a);
					break;

				case "-":
					a = stack.pollLast();
					b = stack.pollLast();
					stack.offer(b - a);
					break;

				case "*":
					a = stack.pollLast();
					b = stack.pollLast();
					stack.offer(b * a);
					break;

				default :
					stack.offer(Integer.parseInt(line[i]));
					break;
			}
		} switch(line[i]){
				case "+":
					a = stack.pollLast();
					b = stack.pollLast();
					stack.offer(b + a);
					break;

				case "-":
					a = stack.pollLast();
					b = stack.pollLast();
					stack.offer(b - a);
					break;

				case "*":
					a = stack.pollLast();
					b = stack.pollLast();
					stack.offer(b * a);
					break;

				default :
					stack.offer(Integer.parseInt(line[i]));
					break;
			} line[i] line i case "+": "+" case "+": a = stack.pollLast() a stack.pollLast() stack.pollLast stack b = stack.pollLast() b stack.pollLast() stack.pollLast stack stack.offer(b + a) stack.offer stack b + a b a break; case "-": "-" case "-": a = stack.pollLast() a stack.pollLast() stack.pollLast stack b = stack.pollLast() b stack.pollLast() stack.pollLast stack stack.offer(b - a) stack.offer stack b - a b a break; case "*": "*" case "*": a = stack.pollLast() a stack.pollLast() stack.pollLast stack b = stack.pollLast() b stack.pollLast() stack.pollLast stack stack.offer(b * a) stack.offer stack b * a b a break; default : default : stack.offer(Integer.parseInt(line[i])) stack.offer stack Integer.parseInt(line[i]) Integer.parseInt Integer line[i] line i break; System.out.println(stack.poll()) System.out.println System.out System System.out stack.poll() stack.poll stack String[] args args
import java.util.Scanner;
import java.util.Arrays;
import java.util.Deque;
import java.util.ArrayDeque;

class Main{
	public static void main(String[] args)throws Exception{
		Scanner scanner = new Scanner(System.in);
		Deque<Integer> stack = new ArrayDeque<>();
		String[] line = scanner.nextLine().split(" ");
		int a,b;

		for(int i = 0; i < line.length; i++){
			switch(line[i]){
				case "+":
					a = stack.pollLast();
					b = stack.pollLast();
					stack.offer(b + a);
					break;

				case "-":
					a = stack.pollLast();
					b = stack.pollLast();
					stack.offer(b - a);
					break;

				case "*":
					a = stack.pollLast();
					b = stack.pollLast();
					stack.offer(b * a);
					break;

				default :
					stack.offer(Integer.parseInt(line[i]));
					break;
			}
		}

		System.out.println(stack.poll());
	}
}