import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Stack;

class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] str = br.readLine().split(" ");
		Stack<Integer> stack = new Stack<Integer>();

		for (int i = 0; i < str.length; i++) {
			if (str[i].equals("+")) {
				stack.push(stack.pop() + stack.pop());
			} else if (str[i].equals("-")) {
				int num01 = stack.pop();
				int num02 = stack.pop();
				stack.push(num02 - num01);
			} else if (str[i].equals("*")) {
				stack.push(stack.pop() * stack.pop());
			} else {
				stack.push(Integer.parseInt(str[i]));
			}
		}
		System.out.println(stack.pop());
	}
} import java.io.BufferedReader; BufferedReader java.io import java.io.InputStreamReader; InputStreamReader java.io import java.util.ArrayList; ArrayList java.util import java.util.Stack; Stack java.util class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] str = br.readLine().split(" ");
		Stack<Integer> stack = new Stack<Integer>();

		for (int i = 0; i < str.length; i++) {
			if (str[i].equals("+")) {
				stack.push(stack.pop() + stack.pop());
			} else if (str[i].equals("-")) {
				int num01 = stack.pop();
				int num02 = stack.pop();
				stack.push(num02 - num01);
			} else if (str[i].equals("*")) {
				stack.push(stack.pop() * stack.pop());
			} else {
				stack.push(Integer.parseInt(str[i]));
			}
		}
		System.out.println(stack.pop());
	}
} Main public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] str = br.readLine().split(" ");
		Stack<Integer> stack = new Stack<Integer>();

		for (int i = 0; i < str.length; i++) {
			if (str[i].equals("+")) {
				stack.push(stack.pop() + stack.pop());
			} else if (str[i].equals("-")) {
				int num01 = stack.pop();
				int num02 = stack.pop();
				stack.push(num02 - num01);
			} else if (str[i].equals("*")) {
				stack.push(stack.pop() * stack.pop());
			} else {
				stack.push(Integer.parseInt(str[i]));
			}
		}
		System.out.println(stack.pop());
	} main {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] str = br.readLine().split(" ");
		Stack<Integer> stack = new Stack<Integer>();

		for (int i = 0; i < str.length; i++) {
			if (str[i].equals("+")) {
				stack.push(stack.pop() + stack.pop());
			} else if (str[i].equals("-")) {
				int num01 = stack.pop();
				int num02 = stack.pop();
				stack.push(num02 - num01);
			} else if (str[i].equals("*")) {
				stack.push(stack.pop() * stack.pop());
			} else {
				stack.push(Integer.parseInt(str[i]));
			}
		}
		System.out.println(stack.pop());
	} BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) String[] str = br.readLine().split(" "); str br.readLine().split(" ") br.readLine().split br.readLine() br.readLine br " " Stack<Integer> stack = new Stack<Integer>(); stack new Stack<Integer>() for (int i = 0; i < str.length; i++) {
			if (str[i].equals("+")) {
				stack.push(stack.pop() + stack.pop());
			} else if (str[i].equals("-")) {
				int num01 = stack.pop();
				int num02 = stack.pop();
				stack.push(num02 - num01);
			} else if (str[i].equals("*")) {
				stack.push(stack.pop() * stack.pop());
			} else {
				stack.push(Integer.parseInt(str[i]));
			}
		} int i = 0; int i = 0; i 0 i < str.length i str.length str str.length i++ i++ i {
			if (str[i].equals("+")) {
				stack.push(stack.pop() + stack.pop());
			} else if (str[i].equals("-")) {
				int num01 = stack.pop();
				int num02 = stack.pop();
				stack.push(num02 - num01);
			} else if (str[i].equals("*")) {
				stack.push(stack.pop() * stack.pop());
			} else {
				stack.push(Integer.parseInt(str[i]));
			}
		} {
			if (str[i].equals("+")) {
				stack.push(stack.pop() + stack.pop());
			} else if (str[i].equals("-")) {
				int num01 = stack.pop();
				int num02 = stack.pop();
				stack.push(num02 - num01);
			} else if (str[i].equals("*")) {
				stack.push(stack.pop() * stack.pop());
			} else {
				stack.push(Integer.parseInt(str[i]));
			}
		} if (str[i].equals("+")) {
				stack.push(stack.pop() + stack.pop());
			} else if (str[i].equals("-")) {
				int num01 = stack.pop();
				int num02 = stack.pop();
				stack.push(num02 - num01);
			} else if (str[i].equals("*")) {
				stack.push(stack.pop() * stack.pop());
			} else {
				stack.push(Integer.parseInt(str[i]));
			} str[i].equals("+") str[i].equals str[i] str i "+" {
				stack.push(stack.pop() + stack.pop());
			} stack.push(stack.pop() + stack.pop()) stack.push stack stack.pop() + stack.pop() stack.pop() stack.pop stack stack.pop() stack.pop stack if (str[i].equals("-")) {
				int num01 = stack.pop();
				int num02 = stack.pop();
				stack.push(num02 - num01);
			} else if (str[i].equals("*")) {
				stack.push(stack.pop() * stack.pop());
			} else {
				stack.push(Integer.parseInt(str[i]));
			} str[i].equals("-") str[i].equals str[i] str i "-" {
				int num01 = stack.pop();
				int num02 = stack.pop();
				stack.push(num02 - num01);
			} int num01 = stack.pop(); num01 stack.pop() stack.pop stack int num02 = stack.pop(); num02 stack.pop() stack.pop stack stack.push(num02 - num01) stack.push stack num02 - num01 num02 num01 if (str[i].equals("*")) {
				stack.push(stack.pop() * stack.pop());
			} else {
				stack.push(Integer.parseInt(str[i]));
			} str[i].equals("*") str[i].equals str[i] str i "*" {
				stack.push(stack.pop() * stack.pop());
			} stack.push(stack.pop() * stack.pop()) stack.push stack stack.pop() * stack.pop() stack.pop() stack.pop stack stack.pop() stack.pop stack {
				stack.push(Integer.parseInt(str[i]));
			} stack.push(Integer.parseInt(str[i])) stack.push stack Integer.parseInt(str[i]) Integer.parseInt Integer str[i] str i System.out.println(stack.pop()) System.out.println System.out System System.out stack.pop() stack.pop stack String[] args args
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Stack;

class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] str = br.readLine().split(" ");
		Stack<Integer> stack = new Stack<Integer>();

		for (int i = 0; i < str.length; i++) {
			if (str[i].equals("+")) {
				stack.push(stack.pop() + stack.pop());
			} else if (str[i].equals("-")) {
				int num01 = stack.pop();
				int num02 = stack.pop();
				stack.push(num02 - num01);
			} else if (str[i].equals("*")) {
				stack.push(stack.pop() * stack.pop());
			} else {
				stack.push(Integer.parseInt(str[i]));
			}
		}
		System.out.println(stack.pop());
	}
}