import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.Deque;
import java.util.Scanner;
import java.util.StringTokenizer;

public class Main {
	void run() {
		Scanner sc = new Scanner(System.in);
		Deque<Integer> Q = new ArrayDeque<>();
		
		StringTokenizer st = new StringTokenizer(sc.nextLine(), " ");
		while(st.hasMoreTokens()) {
			String str = st.nextToken();
			int a, b;
			switch(str.charAt(0)) {
				case '+':
					b = Q.pop();
					a = Q.pop();
					Q.push(a + b);
					break;
				case '-':
					b = Q.pop();
					a = Q.pop();
					Q.push(a - b);
					break;
				case '*':
					b = Q.pop();
					a = Q.pop();
					Q.push(a * b);
					break;
				default:
					Q.push(Integer.parseInt(str));
					break;
			}
		}
		System.out.println(Q.pop());
		sc.close();
	}

	void debug(Object... o) {
		System.out.println(Arrays.deepToString(o));
	}

	public static void main(String[] args) {
		new Main().run();
	}
} import java.util.ArrayDeque; ArrayDeque java.util import java.util.Arrays; Arrays java.util import java.util.Deque; Deque java.util import java.util.Scanner; Scanner java.util import java.util.StringTokenizer; StringTokenizer java.util public class Main {
	void run() {
		Scanner sc = new Scanner(System.in);
		Deque<Integer> Q = new ArrayDeque<>();
		
		StringTokenizer st = new StringTokenizer(sc.nextLine(), " ");
		while(st.hasMoreTokens()) {
			String str = st.nextToken();
			int a, b;
			switch(str.charAt(0)) {
				case '+':
					b = Q.pop();
					a = Q.pop();
					Q.push(a + b);
					break;
				case '-':
					b = Q.pop();
					a = Q.pop();
					Q.push(a - b);
					break;
				case '*':
					b = Q.pop();
					a = Q.pop();
					Q.push(a * b);
					break;
				default:
					Q.push(Integer.parseInt(str));
					break;
			}
		}
		System.out.println(Q.pop());
		sc.close();
	}

	void debug(Object... o) {
		System.out.println(Arrays.deepToString(o));
	}

	public static void main(String[] args) {
		new Main().run();
	}
} Main void run() {
		Scanner sc = new Scanner(System.in);
		Deque<Integer> Q = new ArrayDeque<>();
		
		StringTokenizer st = new StringTokenizer(sc.nextLine(), " ");
		while(st.hasMoreTokens()) {
			String str = st.nextToken();
			int a, b;
			switch(str.charAt(0)) {
				case '+':
					b = Q.pop();
					a = Q.pop();
					Q.push(a + b);
					break;
				case '-':
					b = Q.pop();
					a = Q.pop();
					Q.push(a - b);
					break;
				case '*':
					b = Q.pop();
					a = Q.pop();
					Q.push(a * b);
					break;
				default:
					Q.push(Integer.parseInt(str));
					break;
			}
		}
		System.out.println(Q.pop());
		sc.close();
	} run {
		Scanner sc = new Scanner(System.in);
		Deque<Integer> Q = new ArrayDeque<>();
		
		StringTokenizer st = new StringTokenizer(sc.nextLine(), " ");
		while(st.hasMoreTokens()) {
			String str = st.nextToken();
			int a, b;
			switch(str.charAt(0)) {
				case '+':
					b = Q.pop();
					a = Q.pop();
					Q.push(a + b);
					break;
				case '-':
					b = Q.pop();
					a = Q.pop();
					Q.push(a - b);
					break;
				case '*':
					b = Q.pop();
					a = Q.pop();
					Q.push(a * b);
					break;
				default:
					Q.push(Integer.parseInt(str));
					break;
			}
		}
		System.out.println(Q.pop());
		sc.close();
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) Deque<Integer> Q = new ArrayDeque<>(); Q new ArrayDeque<>() StringTokenizer st = new StringTokenizer(sc.nextLine(), " "); st new StringTokenizer(sc.nextLine(), " ") while(st.hasMoreTokens()) {
			String str = st.nextToken();
			int a, b;
			switch(str.charAt(0)) {
				case '+':
					b = Q.pop();
					a = Q.pop();
					Q.push(a + b);
					break;
				case '-':
					b = Q.pop();
					a = Q.pop();
					Q.push(a - b);
					break;
				case '*':
					b = Q.pop();
					a = Q.pop();
					Q.push(a * b);
					break;
				default:
					Q.push(Integer.parseInt(str));
					break;
			}
		} st.hasMoreTokens() st.hasMoreTokens st {
			String str = st.nextToken();
			int a, b;
			switch(str.charAt(0)) {
				case '+':
					b = Q.pop();
					a = Q.pop();
					Q.push(a + b);
					break;
				case '-':
					b = Q.pop();
					a = Q.pop();
					Q.push(a - b);
					break;
				case '*':
					b = Q.pop();
					a = Q.pop();
					Q.push(a * b);
					break;
				default:
					Q.push(Integer.parseInt(str));
					break;
			}
		} String str = st.nextToken(); str st.nextToken() st.nextToken st int a a b; b switch(str.charAt(0)) {
				case '+':
					b = Q.pop();
					a = Q.pop();
					Q.push(a + b);
					break;
				case '-':
					b = Q.pop();
					a = Q.pop();
					Q.push(a - b);
					break;
				case '*':
					b = Q.pop();
					a = Q.pop();
					Q.push(a * b);
					break;
				default:
					Q.push(Integer.parseInt(str));
					break;
			} str.charAt(0) str.charAt str 0 case '+': '+' case '+': b = Q.pop() b Q.pop() Q.pop Q a = Q.pop() a Q.pop() Q.pop Q Q.push(a + b) Q.push Q a + b a b break; case '-': '-' case '-': b = Q.pop() b Q.pop() Q.pop Q a = Q.pop() a Q.pop() Q.pop Q Q.push(a - b) Q.push Q a - b a b break; case '*': '*' case '*': b = Q.pop() b Q.pop() Q.pop Q a = Q.pop() a Q.pop() Q.pop Q Q.push(a * b) Q.push Q a * b a b break; default: default: Q.push(Integer.parseInt(str)) Q.push Q Integer.parseInt(str) Integer.parseInt Integer str break; System.out.println(Q.pop()) System.out.println System.out System System.out Q.pop() Q.pop Q sc.close() sc.close sc void debug(Object... o) {
		System.out.println(Arrays.deepToString(o));
	} debug {
		System.out.println(Arrays.deepToString(o));
	} System.out.println(Arrays.deepToString(o)) System.out.println System.out System System.out Arrays.deepToString(o) Arrays.deepToString Arrays o Object... o o public static void main(String[] args) {
		new Main().run();
	} main {
		new Main().run();
	} new Main().run() new Main().run new Main() String[] args args public class Main {
	void run() {
		Scanner sc = new Scanner(System.in);
		Deque<Integer> Q = new ArrayDeque<>();
		
		StringTokenizer st = new StringTokenizer(sc.nextLine(), " ");
		while(st.hasMoreTokens()) {
			String str = st.nextToken();
			int a, b;
			switch(str.charAt(0)) {
				case '+':
					b = Q.pop();
					a = Q.pop();
					Q.push(a + b);
					break;
				case '-':
					b = Q.pop();
					a = Q.pop();
					Q.push(a - b);
					break;
				case '*':
					b = Q.pop();
					a = Q.pop();
					Q.push(a * b);
					break;
				default:
					Q.push(Integer.parseInt(str));
					break;
			}
		}
		System.out.println(Q.pop());
		sc.close();
	}

	void debug(Object... o) {
		System.out.println(Arrays.deepToString(o));
	}

	public static void main(String[] args) {
		new Main().run();
	}
} public class Main {
	void run() {
		Scanner sc = new Scanner(System.in);
		Deque<Integer> Q = new ArrayDeque<>();
		
		StringTokenizer st = new StringTokenizer(sc.nextLine(), " ");
		while(st.hasMoreTokens()) {
			String str = st.nextToken();
			int a, b;
			switch(str.charAt(0)) {
				case '+':
					b = Q.pop();
					a = Q.pop();
					Q.push(a + b);
					break;
				case '-':
					b = Q.pop();
					a = Q.pop();
					Q.push(a - b);
					break;
				case '*':
					b = Q.pop();
					a = Q.pop();
					Q.push(a * b);
					break;
				default:
					Q.push(Integer.parseInt(str));
					break;
			}
		}
		System.out.println(Q.pop());
		sc.close();
	}

	void debug(Object... o) {
		System.out.println(Arrays.deepToString(o));
	}

	public static void main(String[] args) {
		new Main().run();
	}
} Main
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.Deque;
import java.util.Scanner;
import java.util.StringTokenizer;

public class Main {
	void run() {
		Scanner sc = new Scanner(System.in);
		Deque<Integer> Q = new ArrayDeque<>();
		
		StringTokenizer st = new StringTokenizer(sc.nextLine(), " ");
		while(st.hasMoreTokens()) {
			String str = st.nextToken();
			int a, b;
			switch(str.charAt(0)) {
				case '+':
					b = Q.pop();
					a = Q.pop();
					Q.push(a + b);
					break;
				case '-':
					b = Q.pop();
					a = Q.pop();
					Q.push(a - b);
					break;
				case '*':
					b = Q.pop();
					a = Q.pop();
					Q.push(a * b);
					break;
				default:
					Q.push(Integer.parseInt(str));
					break;
			}
		}
		System.out.println(Q.pop());
		sc.close();
	}

	void debug(Object... o) {
		System.out.println(Arrays.deepToString(o));
	}

	public static void main(String[] args) {
		new Main().run();
	}
}
