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

public class Main {

	public static void main(String[] args) throws NumberFormatException,
			IOException {
		BufferedReader reader = new BufferedReader(new InputStreamReader(
				System.in));

		String[] strs = reader.readLine().split(" ");
		Stack<Integer> stack = new Stack<Integer>();

		for (String s : strs) {
			if (Character.isDigit(s.charAt(0)))
				stack.push(Integer.parseInt(s));
			else {
				int pop1 = stack.pop();
				int pop2 = stack.pop();
				switch (s.charAt(0)) {
				case '+':
					stack.push(pop2 + pop1);
					break;
				case '-':
					stack.push(pop2 - pop1);
					break;
				default:
					stack.push(pop2 * pop1);
					break;
				}
			}
			/*System.out.println(stack.stream().map(String::valueOf)
					.collect(Collectors.joining(", ", "[", "]")));*/
		}
		System.out.println(stack.pop());
	}
} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io import java.util.Stack; Stack java.util public class Main {

	public static void main(String[] args) throws NumberFormatException,
			IOException {
		BufferedReader reader = new BufferedReader(new InputStreamReader(
				System.in));

		String[] strs = reader.readLine().split(" ");
		Stack<Integer> stack = new Stack<Integer>();

		for (String s : strs) {
			if (Character.isDigit(s.charAt(0)))
				stack.push(Integer.parseInt(s));
			else {
				int pop1 = stack.pop();
				int pop2 = stack.pop();
				switch (s.charAt(0)) {
				case '+':
					stack.push(pop2 + pop1);
					break;
				case '-':
					stack.push(pop2 - pop1);
					break;
				default:
					stack.push(pop2 * pop1);
					break;
				}
			}
			/*System.out.println(stack.stream().map(String::valueOf)
					.collect(Collectors.joining(", ", "[", "]")));*/
		}
		System.out.println(stack.pop());
	}
} Main public static void main(String[] args) throws NumberFormatException,
			IOException {
		BufferedReader reader = new BufferedReader(new InputStreamReader(
				System.in));

		String[] strs = reader.readLine().split(" ");
		Stack<Integer> stack = new Stack<Integer>();

		for (String s : strs) {
			if (Character.isDigit(s.charAt(0)))
				stack.push(Integer.parseInt(s));
			else {
				int pop1 = stack.pop();
				int pop2 = stack.pop();
				switch (s.charAt(0)) {
				case '+':
					stack.push(pop2 + pop1);
					break;
				case '-':
					stack.push(pop2 - pop1);
					break;
				default:
					stack.push(pop2 * pop1);
					break;
				}
			}
			/*System.out.println(stack.stream().map(String::valueOf)
					.collect(Collectors.joining(", ", "[", "]")));*/
		}
		System.out.println(stack.pop());
	} main {
		BufferedReader reader = new BufferedReader(new InputStreamReader(
				System.in));

		String[] strs = reader.readLine().split(" ");
		Stack<Integer> stack = new Stack<Integer>();

		for (String s : strs) {
			if (Character.isDigit(s.charAt(0)))
				stack.push(Integer.parseInt(s));
			else {
				int pop1 = stack.pop();
				int pop2 = stack.pop();
				switch (s.charAt(0)) {
				case '+':
					stack.push(pop2 + pop1);
					break;
				case '-':
					stack.push(pop2 - pop1);
					break;
				default:
					stack.push(pop2 * pop1);
					break;
				}
			}
			/*System.out.println(stack.stream().map(String::valueOf)
					.collect(Collectors.joining(", ", "[", "]")));*/
		}
		System.out.println(stack.pop());
	} BufferedReader reader = new BufferedReader(new InputStreamReader(
				System.in)); reader new BufferedReader(new InputStreamReader(
				System.in)) String[] strs = reader.readLine().split(" "); strs reader.readLine().split(" ") reader.readLine().split reader.readLine() reader.readLine reader " " Stack<Integer> stack = new Stack<Integer>(); stack new Stack<Integer>() for (String s : strs) {
			if (Character.isDigit(s.charAt(0)))
				stack.push(Integer.parseInt(s));
			else {
				int pop1 = stack.pop();
				int pop2 = stack.pop();
				switch (s.charAt(0)) {
				case '+':
					stack.push(pop2 + pop1);
					break;
				case '-':
					stack.push(pop2 - pop1);
					break;
				default:
					stack.push(pop2 * pop1);
					break;
				}
			}
			/*System.out.println(stack.stream().map(String::valueOf)
					.collect(Collectors.joining(", ", "[", "]")));*/
		} String s strs {
			if (Character.isDigit(s.charAt(0)))
				stack.push(Integer.parseInt(s));
			else {
				int pop1 = stack.pop();
				int pop2 = stack.pop();
				switch (s.charAt(0)) {
				case '+':
					stack.push(pop2 + pop1);
					break;
				case '-':
					stack.push(pop2 - pop1);
					break;
				default:
					stack.push(pop2 * pop1);
					break;
				}
			}
			/*System.out.println(stack.stream().map(String::valueOf)
					.collect(Collectors.joining(", ", "[", "]")));*/
		} {
			if (Character.isDigit(s.charAt(0)))
				stack.push(Integer.parseInt(s));
			else {
				int pop1 = stack.pop();
				int pop2 = stack.pop();
				switch (s.charAt(0)) {
				case '+':
					stack.push(pop2 + pop1);
					break;
				case '-':
					stack.push(pop2 - pop1);
					break;
				default:
					stack.push(pop2 * pop1);
					break;
				}
			}
			/*System.out.println(stack.stream().map(String::valueOf)
					.collect(Collectors.joining(", ", "[", "]")));*/
		} if (Character.isDigit(s.charAt(0)))
				stack.push(Integer.parseInt(s));
			else {
				int pop1 = stack.pop();
				int pop2 = stack.pop();
				switch (s.charAt(0)) {
				case '+':
					stack.push(pop2 + pop1);
					break;
				case '-':
					stack.push(pop2 - pop1);
					break;
				default:
					stack.push(pop2 * pop1);
					break;
				}
			} Character.isDigit(s.charAt(0)) Character.isDigit Character s.charAt(0) s.charAt s 0 stack.push(Integer.parseInt(s)) stack.push stack Integer.parseInt(s) Integer.parseInt Integer s {
				int pop1 = stack.pop();
				int pop2 = stack.pop();
				switch (s.charAt(0)) {
				case '+':
					stack.push(pop2 + pop1);
					break;
				case '-':
					stack.push(pop2 - pop1);
					break;
				default:
					stack.push(pop2 * pop1);
					break;
				}
			} int pop1 = stack.pop(); pop1 stack.pop() stack.pop stack int pop2 = stack.pop(); pop2 stack.pop() stack.pop stack switch (s.charAt(0)) {
				case '+':
					stack.push(pop2 + pop1);
					break;
				case '-':
					stack.push(pop2 - pop1);
					break;
				default:
					stack.push(pop2 * pop1);
					break;
				} s.charAt(0) s.charAt s 0 case '+': '+' case '+': stack.push(pop2 + pop1) stack.push stack pop2 + pop1 pop2 pop1 break; case '-': '-' case '-': stack.push(pop2 - pop1) stack.push stack pop2 - pop1 pop2 pop1 break; default: default: stack.push(pop2 * pop1) stack.push stack pop2 * pop1 pop2 pop1 break; System.out.println(stack.pop()) System.out.println System.out System System.out stack.pop() stack.pop stack String[] args args public class Main {

	public static void main(String[] args) throws NumberFormatException,
			IOException {
		BufferedReader reader = new BufferedReader(new InputStreamReader(
				System.in));

		String[] strs = reader.readLine().split(" ");
		Stack<Integer> stack = new Stack<Integer>();

		for (String s : strs) {
			if (Character.isDigit(s.charAt(0)))
				stack.push(Integer.parseInt(s));
			else {
				int pop1 = stack.pop();
				int pop2 = stack.pop();
				switch (s.charAt(0)) {
				case '+':
					stack.push(pop2 + pop1);
					break;
				case '-':
					stack.push(pop2 - pop1);
					break;
				default:
					stack.push(pop2 * pop1);
					break;
				}
			}
			/*System.out.println(stack.stream().map(String::valueOf)
					.collect(Collectors.joining(", ", "[", "]")));*/
		}
		System.out.println(stack.pop());
	}
} public class Main {

	public static void main(String[] args) throws NumberFormatException,
			IOException {
		BufferedReader reader = new BufferedReader(new InputStreamReader(
				System.in));

		String[] strs = reader.readLine().split(" ");
		Stack<Integer> stack = new Stack<Integer>();

		for (String s : strs) {
			if (Character.isDigit(s.charAt(0)))
				stack.push(Integer.parseInt(s));
			else {
				int pop1 = stack.pop();
				int pop2 = stack.pop();
				switch (s.charAt(0)) {
				case '+':
					stack.push(pop2 + pop1);
					break;
				case '-':
					stack.push(pop2 - pop1);
					break;
				default:
					stack.push(pop2 * pop1);
					break;
				}
			}
			/*System.out.println(stack.stream().map(String::valueOf)
					.collect(Collectors.joining(", ", "[", "]")));*/
		}
		System.out.println(stack.pop());
	}
} Main

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

public class Main {

	public static void main(String[] args) throws NumberFormatException,
			IOException {
		BufferedReader reader = new BufferedReader(new InputStreamReader(
				System.in));

		String[] strs = reader.readLine().split(" ");
		Stack<Integer> stack = new Stack<Integer>();

		for (String s : strs) {
			if (Character.isDigit(s.charAt(0)))
				stack.push(Integer.parseInt(s));
			else {
				int pop1 = stack.pop();
				int pop2 = stack.pop();
				switch (s.charAt(0)) {
				case '+':
					stack.push(pop2 + pop1);
					break;
				case '-':
					stack.push(pop2 - pop1);
					break;
				default:
					stack.push(pop2 * pop1);
					break;
				}
			}
			/*System.out.println(stack.stream().map(String::valueOf)
					.collect(Collectors.joining(", ", "[", "]")));*/
		}
		System.out.println(stack.pop());
	}
}