import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.StringTokenizer;

import static java.lang.Integer.decode;
import static java.lang.Integer.parseInt;

/**
 * Elementary data structures - Stack
 */
public class Main {

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

		Deque<Integer> stack = new ArrayDeque<Integer>();

		StringTokenizer st = new StringTokenizer(br.readLine());
		while (st.hasMoreTokens()) {
			String str = st.nextToken();
			int a, b;
			switch (str.charAt(0)) {
				case '+':
					b = stack.pop();
					a = stack.pop();
					stack.push(a + b);
					break;
				case '-':
					b = stack.pop();
					a = stack.pop();
					stack.push(a - b);
					break;
				case '*':
					b = stack.pop();
					a = stack.pop();
					stack.push(a * b);
					break;
				default:
					stack.push(parseInt(str));
					break;
			}
		}
		System.out.println(stack.pop());
	} //end main
} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io import java.util.ArrayDeque; ArrayDeque java.util import java.util.Deque; Deque java.util import java.util.StringTokenizer; StringTokenizer java.util import static java.lang.Integer.decode; import static java.lang.Integer.decode; import static java.lang.Integer.decode; import static java.lang.Integer.parseInt; import static java.lang.Integer.parseInt; import static java.lang.Integer.parseInt; public class Main {

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

		Deque<Integer> stack = new ArrayDeque<Integer>();

		StringTokenizer st = new StringTokenizer(br.readLine());
		while (st.hasMoreTokens()) {
			String str = st.nextToken();
			int a, b;
			switch (str.charAt(0)) {
				case '+':
					b = stack.pop();
					a = stack.pop();
					stack.push(a + b);
					break;
				case '-':
					b = stack.pop();
					a = stack.pop();
					stack.push(a - b);
					break;
				case '*':
					b = stack.pop();
					a = stack.pop();
					stack.push(a * b);
					break;
				default:
					stack.push(parseInt(str));
					break;
			}
		}
		System.out.println(stack.pop());
	} //end main
} Main public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		Deque<Integer> stack = new ArrayDeque<Integer>();

		StringTokenizer st = new StringTokenizer(br.readLine());
		while (st.hasMoreTokens()) {
			String str = st.nextToken();
			int a, b;
			switch (str.charAt(0)) {
				case '+':
					b = stack.pop();
					a = stack.pop();
					stack.push(a + b);
					break;
				case '-':
					b = stack.pop();
					a = stack.pop();
					stack.push(a - b);
					break;
				case '*':
					b = stack.pop();
					a = stack.pop();
					stack.push(a * b);
					break;
				default:
					stack.push(parseInt(str));
					break;
			}
		}
		System.out.println(stack.pop());
	} //end main main {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		Deque<Integer> stack = new ArrayDeque<Integer>();

		StringTokenizer st = new StringTokenizer(br.readLine());
		while (st.hasMoreTokens()) {
			String str = st.nextToken();
			int a, b;
			switch (str.charAt(0)) {
				case '+':
					b = stack.pop();
					a = stack.pop();
					stack.push(a + b);
					break;
				case '-':
					b = stack.pop();
					a = stack.pop();
					stack.push(a - b);
					break;
				case '*':
					b = stack.pop();
					a = stack.pop();
					stack.push(a * b);
					break;
				default:
					stack.push(parseInt(str));
					break;
			}
		}
		System.out.println(stack.pop());
	} BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) Deque<Integer> stack = new ArrayDeque<Integer>(); stack new ArrayDeque<Integer>() StringTokenizer st = new StringTokenizer(br.readLine()); st new StringTokenizer(br.readLine()) while (st.hasMoreTokens()) {
			String str = st.nextToken();
			int a, b;
			switch (str.charAt(0)) {
				case '+':
					b = stack.pop();
					a = stack.pop();
					stack.push(a + b);
					break;
				case '-':
					b = stack.pop();
					a = stack.pop();
					stack.push(a - b);
					break;
				case '*':
					b = stack.pop();
					a = stack.pop();
					stack.push(a * b);
					break;
				default:
					stack.push(parseInt(str));
					break;
			}
		} st.hasMoreTokens() st.hasMoreTokens st {
			String str = st.nextToken();
			int a, b;
			switch (str.charAt(0)) {
				case '+':
					b = stack.pop();
					a = stack.pop();
					stack.push(a + b);
					break;
				case '-':
					b = stack.pop();
					a = stack.pop();
					stack.push(a - b);
					break;
				case '*':
					b = stack.pop();
					a = stack.pop();
					stack.push(a * b);
					break;
				default:
					stack.push(parseInt(str));
					break;
			}
		} String str = st.nextToken(); str st.nextToken() st.nextToken st int a a b; b switch (str.charAt(0)) {
				case '+':
					b = stack.pop();
					a = stack.pop();
					stack.push(a + b);
					break;
				case '-':
					b = stack.pop();
					a = stack.pop();
					stack.push(a - b);
					break;
				case '*':
					b = stack.pop();
					a = stack.pop();
					stack.push(a * b);
					break;
				default:
					stack.push(parseInt(str));
					break;
			} str.charAt(0) str.charAt str 0 case '+': '+' case '+': b = stack.pop() b stack.pop() stack.pop stack a = stack.pop() a stack.pop() stack.pop stack stack.push(a + b) stack.push stack a + b a b break; case '-': '-' case '-': b = stack.pop() b stack.pop() stack.pop stack a = stack.pop() a stack.pop() stack.pop stack stack.push(a - b) stack.push stack a - b a b break; case '*': '*' case '*': b = stack.pop() b stack.pop() stack.pop stack a = stack.pop() a stack.pop() stack.pop stack stack.push(a * b) stack.push stack a * b a b break; default: default: stack.push(parseInt(str)) stack.push stack parseInt(str) parseInt str 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 IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		Deque<Integer> stack = new ArrayDeque<Integer>();

		StringTokenizer st = new StringTokenizer(br.readLine());
		while (st.hasMoreTokens()) {
			String str = st.nextToken();
			int a, b;
			switch (str.charAt(0)) {
				case '+':
					b = stack.pop();
					a = stack.pop();
					stack.push(a + b);
					break;
				case '-':
					b = stack.pop();
					a = stack.pop();
					stack.push(a - b);
					break;
				case '*':
					b = stack.pop();
					a = stack.pop();
					stack.push(a * b);
					break;
				default:
					stack.push(parseInt(str));
					break;
			}
		}
		System.out.println(stack.pop());
	} //end main
} public class Main {

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

		Deque<Integer> stack = new ArrayDeque<Integer>();

		StringTokenizer st = new StringTokenizer(br.readLine());
		while (st.hasMoreTokens()) {
			String str = st.nextToken();
			int a, b;
			switch (str.charAt(0)) {
				case '+':
					b = stack.pop();
					a = stack.pop();
					stack.push(a + b);
					break;
				case '-':
					b = stack.pop();
					a = stack.pop();
					stack.push(a - b);
					break;
				case '*':
					b = stack.pop();
					a = stack.pop();
					stack.push(a * b);
					break;
				default:
					stack.push(parseInt(str));
					break;
			}
		}
		System.out.println(stack.pop());
	} //end main
} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.StringTokenizer;

import static java.lang.Integer.decode;
import static java.lang.Integer.parseInt;

/**
 * Elementary data structures - Stack
 */
public class Main {

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

		Deque<Integer> stack = new ArrayDeque<Integer>();

		StringTokenizer st = new StringTokenizer(br.readLine());
		while (st.hasMoreTokens()) {
			String str = st.nextToken();
			int a, b;
			switch (str.charAt(0)) {
				case '+':
					b = stack.pop();
					a = stack.pop();
					stack.push(a + b);
					break;
				case '-':
					b = stack.pop();
					a = stack.pop();
					stack.push(a - b);
					break;
				case '*':
					b = stack.pop();
					a = stack.pop();
					stack.push(a * b);
					break;
				default:
					stack.push(parseInt(str));
					break;
			}
		}
		System.out.println(stack.pop());
	} //end main
}