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

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		String op = sc.nextLine();
		String[] items = op.split(" ");

		Stack<Integer> stack = new Stack<>();
		for (int i=0; i<items.length; i++) {
			char c = items[i].charAt(0);
			if (c>='0'&&c<='9') {
				stack.push(Integer.parseInt(items[i]));
			} else {
				int b = stack.pop();
				int a = stack.pop();
				if (c=='+') {
					stack.push(a+b);
				} else if (c=='-') {
					stack.push(a-b);
				} else {
					stack.push(a*b);
				}
			}
		}

		System.out.println(stack.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);

		String op = sc.nextLine();
		String[] items = op.split(" ");

		Stack<Integer> stack = new Stack<>();
		for (int i=0; i<items.length; i++) {
			char c = items[i].charAt(0);
			if (c>='0'&&c<='9') {
				stack.push(Integer.parseInt(items[i]));
			} else {
				int b = stack.pop();
				int a = stack.pop();
				if (c=='+') {
					stack.push(a+b);
				} else if (c=='-') {
					stack.push(a-b);
				} else {
					stack.push(a*b);
				}
			}
		}

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

		sc.close();
	}

} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		String op = sc.nextLine();
		String[] items = op.split(" ");

		Stack<Integer> stack = new Stack<>();
		for (int i=0; i<items.length; i++) {
			char c = items[i].charAt(0);
			if (c>='0'&&c<='9') {
				stack.push(Integer.parseInt(items[i]));
			} else {
				int b = stack.pop();
				int a = stack.pop();
				if (c=='+') {
					stack.push(a+b);
				} else if (c=='-') {
					stack.push(a-b);
				} else {
					stack.push(a*b);
				}
			}
		}

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

		sc.close();
	} main {
		Scanner sc = new Scanner(System.in);

		String op = sc.nextLine();
		String[] items = op.split(" ");

		Stack<Integer> stack = new Stack<>();
		for (int i=0; i<items.length; i++) {
			char c = items[i].charAt(0);
			if (c>='0'&&c<='9') {
				stack.push(Integer.parseInt(items[i]));
			} else {
				int b = stack.pop();
				int a = stack.pop();
				if (c=='+') {
					stack.push(a+b);
				} else if (c=='-') {
					stack.push(a-b);
				} else {
					stack.push(a*b);
				}
			}
		}

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

		sc.close();
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String op = sc.nextLine(); op sc.nextLine() sc.nextLine sc String[] items = op.split(" "); items op.split(" ") op.split op " " Stack<Integer> stack = new Stack<>(); stack new Stack<>() for (int i=0; i<items.length; i++) {
			char c = items[i].charAt(0);
			if (c>='0'&&c<='9') {
				stack.push(Integer.parseInt(items[i]));
			} else {
				int b = stack.pop();
				int a = stack.pop();
				if (c=='+') {
					stack.push(a+b);
				} else if (c=='-') {
					stack.push(a-b);
				} else {
					stack.push(a*b);
				}
			}
		} int i=0; int i=0; i 0 i<items.length i items.length items items.length i++ i++ i {
			char c = items[i].charAt(0);
			if (c>='0'&&c<='9') {
				stack.push(Integer.parseInt(items[i]));
			} else {
				int b = stack.pop();
				int a = stack.pop();
				if (c=='+') {
					stack.push(a+b);
				} else if (c=='-') {
					stack.push(a-b);
				} else {
					stack.push(a*b);
				}
			}
		} {
			char c = items[i].charAt(0);
			if (c>='0'&&c<='9') {
				stack.push(Integer.parseInt(items[i]));
			} else {
				int b = stack.pop();
				int a = stack.pop();
				if (c=='+') {
					stack.push(a+b);
				} else if (c=='-') {
					stack.push(a-b);
				} else {
					stack.push(a*b);
				}
			}
		} char c = items[i].charAt(0); c items[i].charAt(0) items[i].charAt items[i] items i 0 if (c>='0'&&c<='9') {
				stack.push(Integer.parseInt(items[i]));
			} else {
				int b = stack.pop();
				int a = stack.pop();
				if (c=='+') {
					stack.push(a+b);
				} else if (c=='-') {
					stack.push(a-b);
				} else {
					stack.push(a*b);
				}
			} c>='0'&&c<='9' c>='0' c '0' c<='9' c '9' {
				stack.push(Integer.parseInt(items[i]));
			} stack.push(Integer.parseInt(items[i])) stack.push stack Integer.parseInt(items[i]) Integer.parseInt Integer items[i] items i {
				int b = stack.pop();
				int a = stack.pop();
				if (c=='+') {
					stack.push(a+b);
				} else if (c=='-') {
					stack.push(a-b);
				} else {
					stack.push(a*b);
				}
			} int b = stack.pop(); b stack.pop() stack.pop stack int a = stack.pop(); a stack.pop() stack.pop stack if (c=='+') {
					stack.push(a+b);
				} else if (c=='-') {
					stack.push(a-b);
				} else {
					stack.push(a*b);
				} c=='+' c '+' {
					stack.push(a+b);
				} stack.push(a+b) stack.push stack a+b a b if (c=='-') {
					stack.push(a-b);
				} else {
					stack.push(a*b);
				} c=='-' c '-' {
					stack.push(a-b);
				} stack.push(a-b) stack.push stack a-b a b {
					stack.push(a*b);
				} stack.push(a*b) stack.push stack a*b a b System.out.println(stack.pop()) System.out.println System.out System System.out stack.pop() stack.pop stack sc.close() sc.close sc String[] args args public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		String op = sc.nextLine();
		String[] items = op.split(" ");

		Stack<Integer> stack = new Stack<>();
		for (int i=0; i<items.length; i++) {
			char c = items[i].charAt(0);
			if (c>='0'&&c<='9') {
				stack.push(Integer.parseInt(items[i]));
			} else {
				int b = stack.pop();
				int a = stack.pop();
				if (c=='+') {
					stack.push(a+b);
				} else if (c=='-') {
					stack.push(a-b);
				} else {
					stack.push(a*b);
				}
			}
		}

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

		sc.close();
	}

} public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		String op = sc.nextLine();
		String[] items = op.split(" ");

		Stack<Integer> stack = new Stack<>();
		for (int i=0; i<items.length; i++) {
			char c = items[i].charAt(0);
			if (c>='0'&&c<='9') {
				stack.push(Integer.parseInt(items[i]));
			} else {
				int b = stack.pop();
				int a = stack.pop();
				if (c=='+') {
					stack.push(a+b);
				} else if (c=='-') {
					stack.push(a-b);
				} else {
					stack.push(a*b);
				}
			}
		}

		System.out.println(stack.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);

		String op = sc.nextLine();
		String[] items = op.split(" ");

		Stack<Integer> stack = new Stack<>();
		for (int i=0; i<items.length; i++) {
			char c = items[i].charAt(0);
			if (c>='0'&&c<='9') {
				stack.push(Integer.parseInt(items[i]));
			} else {
				int b = stack.pop();
				int a = stack.pop();
				if (c=='+') {
					stack.push(a+b);
				} else if (c=='-') {
					stack.push(a-b);
				} else {
					stack.push(a*b);
				}
			}
		}

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

		sc.close();
	}

}