import java.util.Scanner;

/**
 * スタック
 * @author nobu
 * @see <a href="http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_3_A&lang=ja">ALDS1_3_A</a>
 */
public class Main {

	private static int top = 0;
	private static int s[] = new int[1000];

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String input[] = new String[1000];
		input = sc.nextLine().split(" ");

		for (int i = 0; i < input.length; i++) {
			int a, b;
			if ("+".equals(input[i])) {
				a = pop();
				b = pop();
				push(a + b);
			} else if ("-".equals(input[i])) {
				a = pop();
				b = pop();
				push(b - a);
			} else if ("*".equals(input[i])) {
				a = pop();
				b = pop();
				push(a * b);
			} else {
				push(Integer.valueOf(input[i]));
			}
		}

		System.out.println(pop());

		sc.close();
	}

	private static void push(int x) {
		s[++top] = x;
	}

	private static int pop() {
		top--;
		return s[top+1];
	}

}
 import java.util.Scanner; Scanner java.util public class Main {

	private static int top = 0;
	private static int s[] = new int[1000];

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String input[] = new String[1000];
		input = sc.nextLine().split(" ");

		for (int i = 0; i < input.length; i++) {
			int a, b;
			if ("+".equals(input[i])) {
				a = pop();
				b = pop();
				push(a + b);
			} else if ("-".equals(input[i])) {
				a = pop();
				b = pop();
				push(b - a);
			} else if ("*".equals(input[i])) {
				a = pop();
				b = pop();
				push(a * b);
			} else {
				push(Integer.valueOf(input[i]));
			}
		}

		System.out.println(pop());

		sc.close();
	}

	private static void push(int x) {
		s[++top] = x;
	}

	private static int pop() {
		top--;
		return s[top+1];
	}

} Main private static int top = 0; top 0 private static int s[] = new int[1000]; s new int[1000] 1000 public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String input[] = new String[1000];
		input = sc.nextLine().split(" ");

		for (int i = 0; i < input.length; i++) {
			int a, b;
			if ("+".equals(input[i])) {
				a = pop();
				b = pop();
				push(a + b);
			} else if ("-".equals(input[i])) {
				a = pop();
				b = pop();
				push(b - a);
			} else if ("*".equals(input[i])) {
				a = pop();
				b = pop();
				push(a * b);
			} else {
				push(Integer.valueOf(input[i]));
			}
		}

		System.out.println(pop());

		sc.close();
	} main {
		Scanner sc = new Scanner(System.in);
		String input[] = new String[1000];
		input = sc.nextLine().split(" ");

		for (int i = 0; i < input.length; i++) {
			int a, b;
			if ("+".equals(input[i])) {
				a = pop();
				b = pop();
				push(a + b);
			} else if ("-".equals(input[i])) {
				a = pop();
				b = pop();
				push(b - a);
			} else if ("*".equals(input[i])) {
				a = pop();
				b = pop();
				push(a * b);
			} else {
				push(Integer.valueOf(input[i]));
			}
		}

		System.out.println(pop());

		sc.close();
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String input[] = new String[1000]; input new String[1000] 1000 input = sc.nextLine().split(" ") input sc.nextLine().split(" ") sc.nextLine().split sc.nextLine() sc.nextLine sc " " for (int i = 0; i < input.length; i++) {
			int a, b;
			if ("+".equals(input[i])) {
				a = pop();
				b = pop();
				push(a + b);
			} else if ("-".equals(input[i])) {
				a = pop();
				b = pop();
				push(b - a);
			} else if ("*".equals(input[i])) {
				a = pop();
				b = pop();
				push(a * b);
			} else {
				push(Integer.valueOf(input[i]));
			}
		} int i = 0; int i = 0; i 0 i < input.length i input.length input input.length i++ i++ i {
			int a, b;
			if ("+".equals(input[i])) {
				a = pop();
				b = pop();
				push(a + b);
			} else if ("-".equals(input[i])) {
				a = pop();
				b = pop();
				push(b - a);
			} else if ("*".equals(input[i])) {
				a = pop();
				b = pop();
				push(a * b);
			} else {
				push(Integer.valueOf(input[i]));
			}
		} {
			int a, b;
			if ("+".equals(input[i])) {
				a = pop();
				b = pop();
				push(a + b);
			} else if ("-".equals(input[i])) {
				a = pop();
				b = pop();
				push(b - a);
			} else if ("*".equals(input[i])) {
				a = pop();
				b = pop();
				push(a * b);
			} else {
				push(Integer.valueOf(input[i]));
			}
		} int a a b; b if ("+".equals(input[i])) {
				a = pop();
				b = pop();
				push(a + b);
			} else if ("-".equals(input[i])) {
				a = pop();
				b = pop();
				push(b - a);
			} else if ("*".equals(input[i])) {
				a = pop();
				b = pop();
				push(a * b);
			} else {
				push(Integer.valueOf(input[i]));
			} "+".equals(input[i]) "+".equals "+" input[i] input i {
				a = pop();
				b = pop();
				push(a + b);
			} a = pop() a pop() pop b = pop() b pop() pop push(a + b) push a + b a b if ("-".equals(input[i])) {
				a = pop();
				b = pop();
				push(b - a);
			} else if ("*".equals(input[i])) {
				a = pop();
				b = pop();
				push(a * b);
			} else {
				push(Integer.valueOf(input[i]));
			} "-".equals(input[i]) "-".equals "-" input[i] input i {
				a = pop();
				b = pop();
				push(b - a);
			} a = pop() a pop() pop b = pop() b pop() pop push(b - a) push b - a b a if ("*".equals(input[i])) {
				a = pop();
				b = pop();
				push(a * b);
			} else {
				push(Integer.valueOf(input[i]));
			} "*".equals(input[i]) "*".equals "*" input[i] input i {
				a = pop();
				b = pop();
				push(a * b);
			} a = pop() a pop() pop b = pop() b pop() pop push(a * b) push a * b a b {
				push(Integer.valueOf(input[i]));
			} push(Integer.valueOf(input[i])) push Integer.valueOf(input[i]) Integer.valueOf Integer input[i] input i System.out.println(pop()) System.out.println System.out System System.out pop() pop sc.close() sc.close sc String[] args args private static void push(int x) {
		s[++top] = x;
	} push {
		s[++top] = x;
	} s[++top] = x s[++top] s ++top top x int x x private static int pop() {
		top--;
		return s[top+1];
	} pop {
		top--;
		return s[top+1];
	} top-- top return s[top+1]; s[top+1] s top+1 top 1 public class Main {

	private static int top = 0;
	private static int s[] = new int[1000];

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String input[] = new String[1000];
		input = sc.nextLine().split(" ");

		for (int i = 0; i < input.length; i++) {
			int a, b;
			if ("+".equals(input[i])) {
				a = pop();
				b = pop();
				push(a + b);
			} else if ("-".equals(input[i])) {
				a = pop();
				b = pop();
				push(b - a);
			} else if ("*".equals(input[i])) {
				a = pop();
				b = pop();
				push(a * b);
			} else {
				push(Integer.valueOf(input[i]));
			}
		}

		System.out.println(pop());

		sc.close();
	}

	private static void push(int x) {
		s[++top] = x;
	}

	private static int pop() {
		top--;
		return s[top+1];
	}

} public class Main {

	private static int top = 0;
	private static int s[] = new int[1000];

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String input[] = new String[1000];
		input = sc.nextLine().split(" ");

		for (int i = 0; i < input.length; i++) {
			int a, b;
			if ("+".equals(input[i])) {
				a = pop();
				b = pop();
				push(a + b);
			} else if ("-".equals(input[i])) {
				a = pop();
				b = pop();
				push(b - a);
			} else if ("*".equals(input[i])) {
				a = pop();
				b = pop();
				push(a * b);
			} else {
				push(Integer.valueOf(input[i]));
			}
		}

		System.out.println(pop());

		sc.close();
	}

	private static void push(int x) {
		s[++top] = x;
	}

	private static int pop() {
		top--;
		return s[top+1];
	}

} Main
import java.util.Scanner;

/**
 * スタック
 * @author nobu
 * @see <a href="http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_3_A&lang=ja">ALDS1_3_A</a>
 */
public class Main {

	private static int top = 0;
	private static int s[] = new int[1000];

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String input[] = new String[1000];
		input = sc.nextLine().split(" ");

		for (int i = 0; i < input.length; i++) {
			int a, b;
			if ("+".equals(input[i])) {
				a = pop();
				b = pop();
				push(a + b);
			} else if ("-".equals(input[i])) {
				a = pop();
				b = pop();
				push(b - a);
			} else if ("*".equals(input[i])) {
				a = pop();
				b = pop();
				push(a * b);
			} else {
				push(Integer.valueOf(input[i]));
			}
		}

		System.out.println(pop());

		sc.close();
	}

	private static void push(int x) {
		s[++top] = x;
	}

	private static int pop() {
		top--;
		return s[top+1];
	}

}

