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

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		Stack<Integer> st = new Stack<Integer>();
		String str = sc.nextLine();
		int x, y;
		for (String s : str.split(" ")) {
			if (s.equals("+") || s.equals("-") || s.equals("*")) {
				switch (s) {
				case "+":
					y = st.pop();
					x = st.pop();
					st.push(x + y);
					break;
				case "-":
					y = st.pop();
					x = st.pop();
					st.push(x - y);
					break;
				case "*":
					y = st.pop();
					x = st.pop();
					st.push(x * y);
					break;
				}
			} else {
				st.push(Integer.parseInt(s));
			}
		}
		System.out.println(st.pop());
		sc.close();
	}
}
 import java.util.Scanner; Scanner java.util import java.util.Stack; Stack java.util public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		Stack<Integer> st = new Stack<Integer>();
		String str = sc.nextLine();
		int x, y;
		for (String s : str.split(" ")) {
			if (s.equals("+") || s.equals("-") || s.equals("*")) {
				switch (s) {
				case "+":
					y = st.pop();
					x = st.pop();
					st.push(x + y);
					break;
				case "-":
					y = st.pop();
					x = st.pop();
					st.push(x - y);
					break;
				case "*":
					y = st.pop();
					x = st.pop();
					st.push(x * y);
					break;
				}
			} else {
				st.push(Integer.parseInt(s));
			}
		}
		System.out.println(st.pop());
		sc.close();
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		Stack<Integer> st = new Stack<Integer>();
		String str = sc.nextLine();
		int x, y;
		for (String s : str.split(" ")) {
			if (s.equals("+") || s.equals("-") || s.equals("*")) {
				switch (s) {
				case "+":
					y = st.pop();
					x = st.pop();
					st.push(x + y);
					break;
				case "-":
					y = st.pop();
					x = st.pop();
					st.push(x - y);
					break;
				case "*":
					y = st.pop();
					x = st.pop();
					st.push(x * y);
					break;
				}
			} else {
				st.push(Integer.parseInt(s));
			}
		}
		System.out.println(st.pop());
		sc.close();
	} main {
		Scanner sc = new Scanner(System.in);
		Stack<Integer> st = new Stack<Integer>();
		String str = sc.nextLine();
		int x, y;
		for (String s : str.split(" ")) {
			if (s.equals("+") || s.equals("-") || s.equals("*")) {
				switch (s) {
				case "+":
					y = st.pop();
					x = st.pop();
					st.push(x + y);
					break;
				case "-":
					y = st.pop();
					x = st.pop();
					st.push(x - y);
					break;
				case "*":
					y = st.pop();
					x = st.pop();
					st.push(x * y);
					break;
				}
			} else {
				st.push(Integer.parseInt(s));
			}
		}
		System.out.println(st.pop());
		sc.close();
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) Stack<Integer> st = new Stack<Integer>(); st new Stack<Integer>() String str = sc.nextLine(); str sc.nextLine() sc.nextLine sc int x x y; y for (String s : str.split(" ")) {
			if (s.equals("+") || s.equals("-") || s.equals("*")) {
				switch (s) {
				case "+":
					y = st.pop();
					x = st.pop();
					st.push(x + y);
					break;
				case "-":
					y = st.pop();
					x = st.pop();
					st.push(x - y);
					break;
				case "*":
					y = st.pop();
					x = st.pop();
					st.push(x * y);
					break;
				}
			} else {
				st.push(Integer.parseInt(s));
			}
		} String s str.split(" ") str.split str " " {
			if (s.equals("+") || s.equals("-") || s.equals("*")) {
				switch (s) {
				case "+":
					y = st.pop();
					x = st.pop();
					st.push(x + y);
					break;
				case "-":
					y = st.pop();
					x = st.pop();
					st.push(x - y);
					break;
				case "*":
					y = st.pop();
					x = st.pop();
					st.push(x * y);
					break;
				}
			} else {
				st.push(Integer.parseInt(s));
			}
		} {
			if (s.equals("+") || s.equals("-") || s.equals("*")) {
				switch (s) {
				case "+":
					y = st.pop();
					x = st.pop();
					st.push(x + y);
					break;
				case "-":
					y = st.pop();
					x = st.pop();
					st.push(x - y);
					break;
				case "*":
					y = st.pop();
					x = st.pop();
					st.push(x * y);
					break;
				}
			} else {
				st.push(Integer.parseInt(s));
			}
		} if (s.equals("+") || s.equals("-") || s.equals("*")) {
				switch (s) {
				case "+":
					y = st.pop();
					x = st.pop();
					st.push(x + y);
					break;
				case "-":
					y = st.pop();
					x = st.pop();
					st.push(x - y);
					break;
				case "*":
					y = st.pop();
					x = st.pop();
					st.push(x * y);
					break;
				}
			} else {
				st.push(Integer.parseInt(s));
			} s.equals("+") || s.equals("-") || s.equals("*") s.equals("+") || s.equals("-") || s.equals("*") s.equals("+") s.equals s "+" s.equals("-") s.equals s "-" s.equals("*") s.equals s "*" {
				switch (s) {
				case "+":
					y = st.pop();
					x = st.pop();
					st.push(x + y);
					break;
				case "-":
					y = st.pop();
					x = st.pop();
					st.push(x - y);
					break;
				case "*":
					y = st.pop();
					x = st.pop();
					st.push(x * y);
					break;
				}
			} switch (s) {
				case "+":
					y = st.pop();
					x = st.pop();
					st.push(x + y);
					break;
				case "-":
					y = st.pop();
					x = st.pop();
					st.push(x - y);
					break;
				case "*":
					y = st.pop();
					x = st.pop();
					st.push(x * y);
					break;
				} s case "+": "+" case "+": y = st.pop() y st.pop() st.pop st x = st.pop() x st.pop() st.pop st st.push(x + y) st.push st x + y x y break; case "-": "-" case "-": y = st.pop() y st.pop() st.pop st x = st.pop() x st.pop() st.pop st st.push(x - y) st.push st x - y x y break; case "*": "*" case "*": y = st.pop() y st.pop() st.pop st x = st.pop() x st.pop() st.pop st st.push(x * y) st.push st x * y x y break; {
				st.push(Integer.parseInt(s));
			} st.push(Integer.parseInt(s)) st.push st Integer.parseInt(s) Integer.parseInt Integer s System.out.println(st.pop()) System.out.println System.out System System.out st.pop() st.pop st sc.close() sc.close sc String[] args args public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		Stack<Integer> st = new Stack<Integer>();
		String str = sc.nextLine();
		int x, y;
		for (String s : str.split(" ")) {
			if (s.equals("+") || s.equals("-") || s.equals("*")) {
				switch (s) {
				case "+":
					y = st.pop();
					x = st.pop();
					st.push(x + y);
					break;
				case "-":
					y = st.pop();
					x = st.pop();
					st.push(x - y);
					break;
				case "*":
					y = st.pop();
					x = st.pop();
					st.push(x * y);
					break;
				}
			} else {
				st.push(Integer.parseInt(s));
			}
		}
		System.out.println(st.pop());
		sc.close();
	}
} public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		Stack<Integer> st = new Stack<Integer>();
		String str = sc.nextLine();
		int x, y;
		for (String s : str.split(" ")) {
			if (s.equals("+") || s.equals("-") || s.equals("*")) {
				switch (s) {
				case "+":
					y = st.pop();
					x = st.pop();
					st.push(x + y);
					break;
				case "-":
					y = st.pop();
					x = st.pop();
					st.push(x - y);
					break;
				case "*":
					y = st.pop();
					x = st.pop();
					st.push(x * y);
					break;
				}
			} else {
				st.push(Integer.parseInt(s));
			}
		}
		System.out.println(st.pop());
		sc.close();
	}
} Main
import java.util.Scanner;
import java.util.Stack;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		Stack<Integer> st = new Stack<Integer>();
		String str = sc.nextLine();
		int x, y;
		for (String s : str.split(" ")) {
			if (s.equals("+") || s.equals("-") || s.equals("*")) {
				switch (s) {
				case "+":
					y = st.pop();
					x = st.pop();
					st.push(x + y);
					break;
				case "-":
					y = st.pop();
					x = st.pop();
					st.push(x - y);
					break;
				case "*":
					y = st.pop();
					x = st.pop();
					st.push(x * y);
					break;
				}
			} else {
				st.push(Integer.parseInt(s));
			}
		}
		System.out.println(st.pop());
		sc.close();
	}
}

