import java.util.LinkedList;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		solve();
	}

	private static void solve() {
		Scanner sc = new Scanner(System.in);
		String line = sc.nextLine();
		sc.close();

		String[] items = line.split(" ");
		Stack stack = new Stack();

		int op1;
		int op2;
		for (String item : items) {
			switch (item) {
			case "+":
				op2 = stack.pop();
				op1 = stack.pop();
				stack.push(op1 + op2);
				break;
			case "-":
				op2 = stack.pop();
				op1 = stack.pop();
				stack.push(op1 - op2);
				break;
			case "*":
				op2 = stack.pop();
				op1 = stack.pop();
				stack.push(op1 * op2);
				break;
			default:
				stack.push(Integer.parseInt(item));
			}
		}
		System.out.println(stack.pop());
	}
}

class Stack {
	private LinkedList<Integer> stack;
	public Stack() {
		stack = new LinkedList<Integer>();
	}
	public void push(int item) {
		stack.addLast(item);
	}
	public int pop() {
		int ret = stack.getLast();
		stack.removeLast();
		return ret;
	}
} import java.util.LinkedList; LinkedList java.util import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
		solve();
	}

	private static void solve() {
		Scanner sc = new Scanner(System.in);
		String line = sc.nextLine();
		sc.close();

		String[] items = line.split(" ");
		Stack stack = new Stack();

		int op1;
		int op2;
		for (String item : items) {
			switch (item) {
			case "+":
				op2 = stack.pop();
				op1 = stack.pop();
				stack.push(op1 + op2);
				break;
			case "-":
				op2 = stack.pop();
				op1 = stack.pop();
				stack.push(op1 - op2);
				break;
			case "*":
				op2 = stack.pop();
				op1 = stack.pop();
				stack.push(op1 * op2);
				break;
			default:
				stack.push(Integer.parseInt(item));
			}
		}
		System.out.println(stack.pop());
	}
} Main public static void main(String[] args) {
		solve();
	} main {
		solve();
	} solve() solve String[] args args private static void solve() {
		Scanner sc = new Scanner(System.in);
		String line = sc.nextLine();
		sc.close();

		String[] items = line.split(" ");
		Stack stack = new Stack();

		int op1;
		int op2;
		for (String item : items) {
			switch (item) {
			case "+":
				op2 = stack.pop();
				op1 = stack.pop();
				stack.push(op1 + op2);
				break;
			case "-":
				op2 = stack.pop();
				op1 = stack.pop();
				stack.push(op1 - op2);
				break;
			case "*":
				op2 = stack.pop();
				op1 = stack.pop();
				stack.push(op1 * op2);
				break;
			default:
				stack.push(Integer.parseInt(item));
			}
		}
		System.out.println(stack.pop());
	} solve {
		Scanner sc = new Scanner(System.in);
		String line = sc.nextLine();
		sc.close();

		String[] items = line.split(" ");
		Stack stack = new Stack();

		int op1;
		int op2;
		for (String item : items) {
			switch (item) {
			case "+":
				op2 = stack.pop();
				op1 = stack.pop();
				stack.push(op1 + op2);
				break;
			case "-":
				op2 = stack.pop();
				op1 = stack.pop();
				stack.push(op1 - op2);
				break;
			case "*":
				op2 = stack.pop();
				op1 = stack.pop();
				stack.push(op1 * op2);
				break;
			default:
				stack.push(Integer.parseInt(item));
			}
		}
		System.out.println(stack.pop());
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String line = sc.nextLine(); line sc.nextLine() sc.nextLine sc sc.close() sc.close sc String[] items = line.split(" "); items line.split(" ") line.split line " " Stack stack = new Stack(); stack new Stack() int op1; op1 int op2; op2 for (String item : items) {
			switch (item) {
			case "+":
				op2 = stack.pop();
				op1 = stack.pop();
				stack.push(op1 + op2);
				break;
			case "-":
				op2 = stack.pop();
				op1 = stack.pop();
				stack.push(op1 - op2);
				break;
			case "*":
				op2 = stack.pop();
				op1 = stack.pop();
				stack.push(op1 * op2);
				break;
			default:
				stack.push(Integer.parseInt(item));
			}
		} String item items {
			switch (item) {
			case "+":
				op2 = stack.pop();
				op1 = stack.pop();
				stack.push(op1 + op2);
				break;
			case "-":
				op2 = stack.pop();
				op1 = stack.pop();
				stack.push(op1 - op2);
				break;
			case "*":
				op2 = stack.pop();
				op1 = stack.pop();
				stack.push(op1 * op2);
				break;
			default:
				stack.push(Integer.parseInt(item));
			}
		} {
			switch (item) {
			case "+":
				op2 = stack.pop();
				op1 = stack.pop();
				stack.push(op1 + op2);
				break;
			case "-":
				op2 = stack.pop();
				op1 = stack.pop();
				stack.push(op1 - op2);
				break;
			case "*":
				op2 = stack.pop();
				op1 = stack.pop();
				stack.push(op1 * op2);
				break;
			default:
				stack.push(Integer.parseInt(item));
			}
		} switch (item) {
			case "+":
				op2 = stack.pop();
				op1 = stack.pop();
				stack.push(op1 + op2);
				break;
			case "-":
				op2 = stack.pop();
				op1 = stack.pop();
				stack.push(op1 - op2);
				break;
			case "*":
				op2 = stack.pop();
				op1 = stack.pop();
				stack.push(op1 * op2);
				break;
			default:
				stack.push(Integer.parseInt(item));
			} item case "+": "+" case "+": op2 = stack.pop() op2 stack.pop() stack.pop stack op1 = stack.pop() op1 stack.pop() stack.pop stack stack.push(op1 + op2) stack.push stack op1 + op2 op1 op2 break; case "-": "-" case "-": op2 = stack.pop() op2 stack.pop() stack.pop stack op1 = stack.pop() op1 stack.pop() stack.pop stack stack.push(op1 - op2) stack.push stack op1 - op2 op1 op2 break; case "*": "*" case "*": op2 = stack.pop() op2 stack.pop() stack.pop stack op1 = stack.pop() op1 stack.pop() stack.pop stack stack.push(op1 * op2) stack.push stack op1 * op2 op1 op2 break; default: default: stack.push(Integer.parseInt(item)) stack.push stack Integer.parseInt(item) Integer.parseInt Integer item System.out.println(stack.pop()) System.out.println System.out System System.out stack.pop() stack.pop stack class Stack {
	private LinkedList<Integer> stack;
	public Stack() {
		stack = new LinkedList<Integer>();
	}
	public void push(int item) {
		stack.addLast(item);
	}
	public int pop() {
		int ret = stack.getLast();
		stack.removeLast();
		return ret;
	}
} Stack private LinkedList<Integer> stack; stack public Stack() {
		stack = new LinkedList<Integer>();
	} Stack {
		stack = new LinkedList<Integer>();
	} stack = new LinkedList<Integer>() stack new LinkedList<Integer>() public void push(int item) {
		stack.addLast(item);
	} push {
		stack.addLast(item);
	} stack.addLast(item) stack.addLast stack item int item item public int pop() {
		int ret = stack.getLast();
		stack.removeLast();
		return ret;
	} pop {
		int ret = stack.getLast();
		stack.removeLast();
		return ret;
	} int ret = stack.getLast(); ret stack.getLast() stack.getLast stack stack.removeLast() stack.removeLast stack return ret; ret public class Main {
	public static void main(String[] args) {
		solve();
	}

	private static void solve() {
		Scanner sc = new Scanner(System.in);
		String line = sc.nextLine();
		sc.close();

		String[] items = line.split(" ");
		Stack stack = new Stack();

		int op1;
		int op2;
		for (String item : items) {
			switch (item) {
			case "+":
				op2 = stack.pop();
				op1 = stack.pop();
				stack.push(op1 + op2);
				break;
			case "-":
				op2 = stack.pop();
				op1 = stack.pop();
				stack.push(op1 - op2);
				break;
			case "*":
				op2 = stack.pop();
				op1 = stack.pop();
				stack.push(op1 * op2);
				break;
			default:
				stack.push(Integer.parseInt(item));
			}
		}
		System.out.println(stack.pop());
	}
} public class Main {
	public static void main(String[] args) {
		solve();
	}

	private static void solve() {
		Scanner sc = new Scanner(System.in);
		String line = sc.nextLine();
		sc.close();

		String[] items = line.split(" ");
		Stack stack = new Stack();

		int op1;
		int op2;
		for (String item : items) {
			switch (item) {
			case "+":
				op2 = stack.pop();
				op1 = stack.pop();
				stack.push(op1 + op2);
				break;
			case "-":
				op2 = stack.pop();
				op1 = stack.pop();
				stack.push(op1 - op2);
				break;
			case "*":
				op2 = stack.pop();
				op1 = stack.pop();
				stack.push(op1 * op2);
				break;
			default:
				stack.push(Integer.parseInt(item));
			}
		}
		System.out.println(stack.pop());
	}
} Main
import java.util.LinkedList;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		solve();
	}

	private static void solve() {
		Scanner sc = new Scanner(System.in);
		String line = sc.nextLine();
		sc.close();

		String[] items = line.split(" ");
		Stack stack = new Stack();

		int op1;
		int op2;
		for (String item : items) {
			switch (item) {
			case "+":
				op2 = stack.pop();
				op1 = stack.pop();
				stack.push(op1 + op2);
				break;
			case "-":
				op2 = stack.pop();
				op1 = stack.pop();
				stack.push(op1 - op2);
				break;
			case "*":
				op2 = stack.pop();
				op1 = stack.pop();
				stack.push(op1 * op2);
				break;
			default:
				stack.push(Integer.parseInt(item));
			}
		}
		System.out.println(stack.pop());
	}
}

class Stack {
	private LinkedList<Integer> stack;
	public Stack() {
		stack = new LinkedList<Integer>();
	}
	public void push(int item) {
		stack.addLast(item);
	}
	public int pop() {
		int ret = stack.getLast();
		stack.removeLast();
		return ret;
	}
}