import java.util.Scanner;
import java.util.Stack;

public class Main {
	public static void main(String[] args){
		String str;
		int num1, num2, result = 0;
		Scanner in = new Scanner(System.in);
		Stack<Integer> poland = new Stack<Integer>();

		while(in.hasNext()){
			str = in.next();

			if(str.equals("+") || str.equals("-") || str.equals("*")){
				num1 = poland.pop();
				num2 = poland.pop();
				if(str.equals("+")) result = num2 + num1;
				else if(str.equals("-")) result = num2 - num1;
				else if(str.equals("*")) result = num2 * num1;
				poland.push(result);
			}
			else{
				poland.push(Integer.parseInt(str));
			}
		}
		System.out.println(result);
	}
} import java.util.Scanner; Scanner java.util import java.util.Stack; Stack java.util public class Main {
	public static void main(String[] args){
		String str;
		int num1, num2, result = 0;
		Scanner in = new Scanner(System.in);
		Stack<Integer> poland = new Stack<Integer>();

		while(in.hasNext()){
			str = in.next();

			if(str.equals("+") || str.equals("-") || str.equals("*")){
				num1 = poland.pop();
				num2 = poland.pop();
				if(str.equals("+")) result = num2 + num1;
				else if(str.equals("-")) result = num2 - num1;
				else if(str.equals("*")) result = num2 * num1;
				poland.push(result);
			}
			else{
				poland.push(Integer.parseInt(str));
			}
		}
		System.out.println(result);
	}
} Main public static void main(String[] args){
		String str;
		int num1, num2, result = 0;
		Scanner in = new Scanner(System.in);
		Stack<Integer> poland = new Stack<Integer>();

		while(in.hasNext()){
			str = in.next();

			if(str.equals("+") || str.equals("-") || str.equals("*")){
				num1 = poland.pop();
				num2 = poland.pop();
				if(str.equals("+")) result = num2 + num1;
				else if(str.equals("-")) result = num2 - num1;
				else if(str.equals("*")) result = num2 * num1;
				poland.push(result);
			}
			else{
				poland.push(Integer.parseInt(str));
			}
		}
		System.out.println(result);
	} main {
		String str;
		int num1, num2, result = 0;
		Scanner in = new Scanner(System.in);
		Stack<Integer> poland = new Stack<Integer>();

		while(in.hasNext()){
			str = in.next();

			if(str.equals("+") || str.equals("-") || str.equals("*")){
				num1 = poland.pop();
				num2 = poland.pop();
				if(str.equals("+")) result = num2 + num1;
				else if(str.equals("-")) result = num2 - num1;
				else if(str.equals("*")) result = num2 * num1;
				poland.push(result);
			}
			else{
				poland.push(Integer.parseInt(str));
			}
		}
		System.out.println(result);
	} String str; str int num1 num1 num2 num2 result = 0; result 0 Scanner in = new Scanner(System.in); in new Scanner(System.in) Stack<Integer> poland = new Stack<Integer>(); poland new Stack<Integer>() while(in.hasNext()){
			str = in.next();

			if(str.equals("+") || str.equals("-") || str.equals("*")){
				num1 = poland.pop();
				num2 = poland.pop();
				if(str.equals("+")) result = num2 + num1;
				else if(str.equals("-")) result = num2 - num1;
				else if(str.equals("*")) result = num2 * num1;
				poland.push(result);
			}
			else{
				poland.push(Integer.parseInt(str));
			}
		} in.hasNext() in.hasNext in {
			str = in.next();

			if(str.equals("+") || str.equals("-") || str.equals("*")){
				num1 = poland.pop();
				num2 = poland.pop();
				if(str.equals("+")) result = num2 + num1;
				else if(str.equals("-")) result = num2 - num1;
				else if(str.equals("*")) result = num2 * num1;
				poland.push(result);
			}
			else{
				poland.push(Integer.parseInt(str));
			}
		} str = in.next() str in.next() in.next in if(str.equals("+") || str.equals("-") || str.equals("*")){
				num1 = poland.pop();
				num2 = poland.pop();
				if(str.equals("+")) result = num2 + num1;
				else if(str.equals("-")) result = num2 - num1;
				else if(str.equals("*")) result = num2 * num1;
				poland.push(result);
			}
			else{
				poland.push(Integer.parseInt(str));
			} str.equals("+") || str.equals("-") || str.equals("*") str.equals("+") || str.equals("-") || str.equals("*") str.equals("+") str.equals str "+" str.equals("-") str.equals str "-" str.equals("*") str.equals str "*" {
				num1 = poland.pop();
				num2 = poland.pop();
				if(str.equals("+")) result = num2 + num1;
				else if(str.equals("-")) result = num2 - num1;
				else if(str.equals("*")) result = num2 * num1;
				poland.push(result);
			} num1 = poland.pop() num1 poland.pop() poland.pop poland num2 = poland.pop() num2 poland.pop() poland.pop poland if(str.equals("+")) result = num2 + num1;
				else if(str.equals("-")) result = num2 - num1;
				else if(str.equals("*")) result = num2 * num1; str.equals("+") str.equals str "+" result = num2 + num1 result num2 + num1 num2 num1 if(str.equals("-")) result = num2 - num1;
				else if(str.equals("*")) result = num2 * num1; str.equals("-") str.equals str "-" result = num2 - num1 result num2 - num1 num2 num1 if(str.equals("*")) result = num2 * num1; str.equals("*") str.equals str "*" result = num2 * num1 result num2 * num1 num2 num1 poland.push(result) poland.push poland result {
				poland.push(Integer.parseInt(str));
			} poland.push(Integer.parseInt(str)) poland.push poland Integer.parseInt(str) Integer.parseInt Integer str System.out.println(result) System.out.println System.out System System.out result String[] args args public class Main {
	public static void main(String[] args){
		String str;
		int num1, num2, result = 0;
		Scanner in = new Scanner(System.in);
		Stack<Integer> poland = new Stack<Integer>();

		while(in.hasNext()){
			str = in.next();

			if(str.equals("+") || str.equals("-") || str.equals("*")){
				num1 = poland.pop();
				num2 = poland.pop();
				if(str.equals("+")) result = num2 + num1;
				else if(str.equals("-")) result = num2 - num1;
				else if(str.equals("*")) result = num2 * num1;
				poland.push(result);
			}
			else{
				poland.push(Integer.parseInt(str));
			}
		}
		System.out.println(result);
	}
} public class Main {
	public static void main(String[] args){
		String str;
		int num1, num2, result = 0;
		Scanner in = new Scanner(System.in);
		Stack<Integer> poland = new Stack<Integer>();

		while(in.hasNext()){
			str = in.next();

			if(str.equals("+") || str.equals("-") || str.equals("*")){
				num1 = poland.pop();
				num2 = poland.pop();
				if(str.equals("+")) result = num2 + num1;
				else if(str.equals("-")) result = num2 - num1;
				else if(str.equals("*")) result = num2 * num1;
				poland.push(result);
			}
			else{
				poland.push(Integer.parseInt(str));
			}
		}
		System.out.println(result);
	}
} Main
import java.util.Scanner;
import java.util.Stack;

public class Main {
	public static void main(String[] args){
		String str;
		int num1, num2, result = 0;
		Scanner in = new Scanner(System.in);
		Stack<Integer> poland = new Stack<Integer>();

		while(in.hasNext()){
			str = in.next();

			if(str.equals("+") || str.equals("-") || str.equals("*")){
				num1 = poland.pop();
				num2 = poland.pop();
				if(str.equals("+")) result = num2 + num1;
				else if(str.equals("-")) result = num2 - num1;
				else if(str.equals("*")) result = num2 * num1;
				poland.push(result);
			}
			else{
				poland.push(Integer.parseInt(str));
			}
		}
		System.out.println(result);
	}
}