import java.io.*;

class Main {
	public static void main(String[] args) throws IOException{
		BufferedReader r = new BufferedReader(new InputStreamReader(System.in));
		
		String[] s = r.readLine().split(" ");
		int[] stack = new int[s.length];
		int topOfStack = 0;
		
		for (int i = 0; i < s.length; i++) {
			switch (s[i].charAt(0)) {
				case '+':
					topOfStack--;
					stack[topOfStack-1] = stack[topOfStack - 1] + stack[topOfStack];
					break;
				case '-':
					topOfStack--;
					stack[topOfStack-1] = stack[topOfStack - 1] - stack[topOfStack];
					break;
				case '*':
					topOfStack--;
					stack[topOfStack-1] = stack[topOfStack - 1] * stack[topOfStack];
					break;
				default:
					stack[topOfStack] = Integer.parseInt(s[i]);
					topOfStack++;
					break;
			}
		}
		
		System.out.println(stack[0]);
	}
	
} import java.io.*; io.* java class Main {
	public static void main(String[] args) throws IOException{
		BufferedReader r = new BufferedReader(new InputStreamReader(System.in));
		
		String[] s = r.readLine().split(" ");
		int[] stack = new int[s.length];
		int topOfStack = 0;
		
		for (int i = 0; i < s.length; i++) {
			switch (s[i].charAt(0)) {
				case '+':
					topOfStack--;
					stack[topOfStack-1] = stack[topOfStack - 1] + stack[topOfStack];
					break;
				case '-':
					topOfStack--;
					stack[topOfStack-1] = stack[topOfStack - 1] - stack[topOfStack];
					break;
				case '*':
					topOfStack--;
					stack[topOfStack-1] = stack[topOfStack - 1] * stack[topOfStack];
					break;
				default:
					stack[topOfStack] = Integer.parseInt(s[i]);
					topOfStack++;
					break;
			}
		}
		
		System.out.println(stack[0]);
	}
	
} Main public static void main(String[] args) throws IOException{
		BufferedReader r = new BufferedReader(new InputStreamReader(System.in));
		
		String[] s = r.readLine().split(" ");
		int[] stack = new int[s.length];
		int topOfStack = 0;
		
		for (int i = 0; i < s.length; i++) {
			switch (s[i].charAt(0)) {
				case '+':
					topOfStack--;
					stack[topOfStack-1] = stack[topOfStack - 1] + stack[topOfStack];
					break;
				case '-':
					topOfStack--;
					stack[topOfStack-1] = stack[topOfStack - 1] - stack[topOfStack];
					break;
				case '*':
					topOfStack--;
					stack[topOfStack-1] = stack[topOfStack - 1] * stack[topOfStack];
					break;
				default:
					stack[topOfStack] = Integer.parseInt(s[i]);
					topOfStack++;
					break;
			}
		}
		
		System.out.println(stack[0]);
	} main {
		BufferedReader r = new BufferedReader(new InputStreamReader(System.in));
		
		String[] s = r.readLine().split(" ");
		int[] stack = new int[s.length];
		int topOfStack = 0;
		
		for (int i = 0; i < s.length; i++) {
			switch (s[i].charAt(0)) {
				case '+':
					topOfStack--;
					stack[topOfStack-1] = stack[topOfStack - 1] + stack[topOfStack];
					break;
				case '-':
					topOfStack--;
					stack[topOfStack-1] = stack[topOfStack - 1] - stack[topOfStack];
					break;
				case '*':
					topOfStack--;
					stack[topOfStack-1] = stack[topOfStack - 1] * stack[topOfStack];
					break;
				default:
					stack[topOfStack] = Integer.parseInt(s[i]);
					topOfStack++;
					break;
			}
		}
		
		System.out.println(stack[0]);
	} BufferedReader r = new BufferedReader(new InputStreamReader(System.in)); r new BufferedReader(new InputStreamReader(System.in)) String[] s = r.readLine().split(" "); s r.readLine().split(" ") r.readLine().split r.readLine() r.readLine r " " int[] stack = new int[s.length]; stack new int[s.length] s.length s s.length int topOfStack = 0; topOfStack 0 for (int i = 0; i < s.length; i++) {
			switch (s[i].charAt(0)) {
				case '+':
					topOfStack--;
					stack[topOfStack-1] = stack[topOfStack - 1] + stack[topOfStack];
					break;
				case '-':
					topOfStack--;
					stack[topOfStack-1] = stack[topOfStack - 1] - stack[topOfStack];
					break;
				case '*':
					topOfStack--;
					stack[topOfStack-1] = stack[topOfStack - 1] * stack[topOfStack];
					break;
				default:
					stack[topOfStack] = Integer.parseInt(s[i]);
					topOfStack++;
					break;
			}
		} int i = 0; int i = 0; i 0 i < s.length i s.length s s.length i++ i++ i {
			switch (s[i].charAt(0)) {
				case '+':
					topOfStack--;
					stack[topOfStack-1] = stack[topOfStack - 1] + stack[topOfStack];
					break;
				case '-':
					topOfStack--;
					stack[topOfStack-1] = stack[topOfStack - 1] - stack[topOfStack];
					break;
				case '*':
					topOfStack--;
					stack[topOfStack-1] = stack[topOfStack - 1] * stack[topOfStack];
					break;
				default:
					stack[topOfStack] = Integer.parseInt(s[i]);
					topOfStack++;
					break;
			}
		} {
			switch (s[i].charAt(0)) {
				case '+':
					topOfStack--;
					stack[topOfStack-1] = stack[topOfStack - 1] + stack[topOfStack];
					break;
				case '-':
					topOfStack--;
					stack[topOfStack-1] = stack[topOfStack - 1] - stack[topOfStack];
					break;
				case '*':
					topOfStack--;
					stack[topOfStack-1] = stack[topOfStack - 1] * stack[topOfStack];
					break;
				default:
					stack[topOfStack] = Integer.parseInt(s[i]);
					topOfStack++;
					break;
			}
		} switch (s[i].charAt(0)) {
				case '+':
					topOfStack--;
					stack[topOfStack-1] = stack[topOfStack - 1] + stack[topOfStack];
					break;
				case '-':
					topOfStack--;
					stack[topOfStack-1] = stack[topOfStack - 1] - stack[topOfStack];
					break;
				case '*':
					topOfStack--;
					stack[topOfStack-1] = stack[topOfStack - 1] * stack[topOfStack];
					break;
				default:
					stack[topOfStack] = Integer.parseInt(s[i]);
					topOfStack++;
					break;
			} s[i].charAt(0) s[i].charAt s[i] s i 0 case '+': '+' case '+': topOfStack-- topOfStack stack[topOfStack-1] = stack[topOfStack - 1] + stack[topOfStack] stack[topOfStack-1] stack topOfStack-1 topOfStack 1 stack[topOfStack - 1] + stack[topOfStack] stack[topOfStack - 1] stack topOfStack - 1 topOfStack 1 stack[topOfStack] stack topOfStack break; case '-': '-' case '-': topOfStack-- topOfStack stack[topOfStack-1] = stack[topOfStack - 1] - stack[topOfStack] stack[topOfStack-1] stack topOfStack-1 topOfStack 1 stack[topOfStack - 1] - stack[topOfStack] stack[topOfStack - 1] stack topOfStack - 1 topOfStack 1 stack[topOfStack] stack topOfStack break; case '*': '*' case '*': topOfStack-- topOfStack stack[topOfStack-1] = stack[topOfStack - 1] * stack[topOfStack] stack[topOfStack-1] stack topOfStack-1 topOfStack 1 stack[topOfStack - 1] * stack[topOfStack] stack[topOfStack - 1] stack topOfStack - 1 topOfStack 1 stack[topOfStack] stack topOfStack break; default: default: stack[topOfStack] = Integer.parseInt(s[i]) stack[topOfStack] stack topOfStack Integer.parseInt(s[i]) Integer.parseInt Integer s[i] s i topOfStack++ topOfStack break; System.out.println(stack[0]) System.out.println System.out System System.out stack[0] stack 0 String[] args args
import java.io.*;

class Main {
	public static void main(String[] args) throws IOException{
		BufferedReader r = new BufferedReader(new InputStreamReader(System.in));
		
		String[] s = r.readLine().split(" ");
		int[] stack = new int[s.length];
		int topOfStack = 0;
		
		for (int i = 0; i < s.length; i++) {
			switch (s[i].charAt(0)) {
				case '+':
					topOfStack--;
					stack[topOfStack-1] = stack[topOfStack - 1] + stack[topOfStack];
					break;
				case '-':
					topOfStack--;
					stack[topOfStack-1] = stack[topOfStack - 1] - stack[topOfStack];
					break;
				case '*':
					topOfStack--;
					stack[topOfStack-1] = stack[topOfStack - 1] * stack[topOfStack];
					break;
				default:
					stack[topOfStack] = Integer.parseInt(s[i]);
					topOfStack++;
					break;
			}
		}
		
		System.out.println(stack[0]);
	}
	
}
