import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		String string = sc.nextLine();
		String[] a = string.split(" ");

		Poppin poppin = new Poppin(1000);

		for (int i = 0; i < a.length; i++) {

			if (a[i].equals("+")) {
				int p = poppin.pop();
				int q = poppin.pop();
				poppin.add(p + q);
				continue;

			}
			if (a[i].equals("-")) {

				int p = poppin.pop();
				int q = poppin.pop();
				poppin.add(q - p);
				continue;
			}
			if (a[i].equals("*")) {

				int p = poppin.pop();
				int q = poppin.pop();
				poppin.add(p * q);
				continue;
			}

			int n = Integer.parseInt(a[i]);
			poppin.add(n);

		}

		System.out.println(poppin.pop());

	}

}

class Poppin {
	int top = 0;
	int[] a;

	public Poppin(int n) {
		a = new int[n];
	}

	void add(int x) {
		top++;
		a[top] = x;

	}

	int pop() {
		int x = a[top];
		top--;
		return x;
	}
} import java.util.Scanner; Scanner java.util public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		String string = sc.nextLine();
		String[] a = string.split(" ");

		Poppin poppin = new Poppin(1000);

		for (int i = 0; i < a.length; i++) {

			if (a[i].equals("+")) {
				int p = poppin.pop();
				int q = poppin.pop();
				poppin.add(p + q);
				continue;

			}
			if (a[i].equals("-")) {

				int p = poppin.pop();
				int q = poppin.pop();
				poppin.add(q - p);
				continue;
			}
			if (a[i].equals("*")) {

				int p = poppin.pop();
				int q = poppin.pop();
				poppin.add(p * q);
				continue;
			}

			int n = Integer.parseInt(a[i]);
			poppin.add(n);

		}

		System.out.println(poppin.pop());

	}

} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		String string = sc.nextLine();
		String[] a = string.split(" ");

		Poppin poppin = new Poppin(1000);

		for (int i = 0; i < a.length; i++) {

			if (a[i].equals("+")) {
				int p = poppin.pop();
				int q = poppin.pop();
				poppin.add(p + q);
				continue;

			}
			if (a[i].equals("-")) {

				int p = poppin.pop();
				int q = poppin.pop();
				poppin.add(q - p);
				continue;
			}
			if (a[i].equals("*")) {

				int p = poppin.pop();
				int q = poppin.pop();
				poppin.add(p * q);
				continue;
			}

			int n = Integer.parseInt(a[i]);
			poppin.add(n);

		}

		System.out.println(poppin.pop());

	} main {
		Scanner sc = new Scanner(System.in);

		String string = sc.nextLine();
		String[] a = string.split(" ");

		Poppin poppin = new Poppin(1000);

		for (int i = 0; i < a.length; i++) {

			if (a[i].equals("+")) {
				int p = poppin.pop();
				int q = poppin.pop();
				poppin.add(p + q);
				continue;

			}
			if (a[i].equals("-")) {

				int p = poppin.pop();
				int q = poppin.pop();
				poppin.add(q - p);
				continue;
			}
			if (a[i].equals("*")) {

				int p = poppin.pop();
				int q = poppin.pop();
				poppin.add(p * q);
				continue;
			}

			int n = Integer.parseInt(a[i]);
			poppin.add(n);

		}

		System.out.println(poppin.pop());

	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String string = sc.nextLine(); string sc.nextLine() sc.nextLine sc String[] a = string.split(" "); a string.split(" ") string.split string " " Poppin poppin = new Poppin(1000); poppin new Poppin(1000) for (int i = 0; i < a.length; i++) {

			if (a[i].equals("+")) {
				int p = poppin.pop();
				int q = poppin.pop();
				poppin.add(p + q);
				continue;

			}
			if (a[i].equals("-")) {

				int p = poppin.pop();
				int q = poppin.pop();
				poppin.add(q - p);
				continue;
			}
			if (a[i].equals("*")) {

				int p = poppin.pop();
				int q = poppin.pop();
				poppin.add(p * q);
				continue;
			}

			int n = Integer.parseInt(a[i]);
			poppin.add(n);

		} int i = 0; int i = 0; i 0 i < a.length i a.length a a.length i++ i++ i {

			if (a[i].equals("+")) {
				int p = poppin.pop();
				int q = poppin.pop();
				poppin.add(p + q);
				continue;

			}
			if (a[i].equals("-")) {

				int p = poppin.pop();
				int q = poppin.pop();
				poppin.add(q - p);
				continue;
			}
			if (a[i].equals("*")) {

				int p = poppin.pop();
				int q = poppin.pop();
				poppin.add(p * q);
				continue;
			}

			int n = Integer.parseInt(a[i]);
			poppin.add(n);

		} {

			if (a[i].equals("+")) {
				int p = poppin.pop();
				int q = poppin.pop();
				poppin.add(p + q);
				continue;

			}
			if (a[i].equals("-")) {

				int p = poppin.pop();
				int q = poppin.pop();
				poppin.add(q - p);
				continue;
			}
			if (a[i].equals("*")) {

				int p = poppin.pop();
				int q = poppin.pop();
				poppin.add(p * q);
				continue;
			}

			int n = Integer.parseInt(a[i]);
			poppin.add(n);

		} if (a[i].equals("+")) {
				int p = poppin.pop();
				int q = poppin.pop();
				poppin.add(p + q);
				continue;

			} a[i].equals("+") a[i].equals a[i] a i "+" {
				int p = poppin.pop();
				int q = poppin.pop();
				poppin.add(p + q);
				continue;

			} int p = poppin.pop(); p poppin.pop() poppin.pop poppin int q = poppin.pop(); q poppin.pop() poppin.pop poppin poppin.add(p + q) poppin.add poppin p + q p q continue; if (a[i].equals("-")) {

				int p = poppin.pop();
				int q = poppin.pop();
				poppin.add(q - p);
				continue;
			} a[i].equals("-") a[i].equals a[i] a i "-" {

				int p = poppin.pop();
				int q = poppin.pop();
				poppin.add(q - p);
				continue;
			} int p = poppin.pop(); p poppin.pop() poppin.pop poppin int q = poppin.pop(); q poppin.pop() poppin.pop poppin poppin.add(q - p) poppin.add poppin q - p q p continue; if (a[i].equals("*")) {

				int p = poppin.pop();
				int q = poppin.pop();
				poppin.add(p * q);
				continue;
			} a[i].equals("*") a[i].equals a[i] a i "*" {

				int p = poppin.pop();
				int q = poppin.pop();
				poppin.add(p * q);
				continue;
			} int p = poppin.pop(); p poppin.pop() poppin.pop poppin int q = poppin.pop(); q poppin.pop() poppin.pop poppin poppin.add(p * q) poppin.add poppin p * q p q continue; int n = Integer.parseInt(a[i]); n Integer.parseInt(a[i]) Integer.parseInt Integer a[i] a i poppin.add(n) poppin.add poppin n System.out.println(poppin.pop()) System.out.println System.out System System.out poppin.pop() poppin.pop poppin String[] args args class Poppin {
	int top = 0;
	int[] a;

	public Poppin(int n) {
		a = new int[n];
	}

	void add(int x) {
		top++;
		a[top] = x;

	}

	int pop() {
		int x = a[top];
		top--;
		return x;
	}
} Poppin int top = 0; top 0 int[] a; a public Poppin(int n) {
		a = new int[n];
	} Poppin {
		a = new int[n];
	} a = new int[n] a new int[n] n int n n void add(int x) {
		top++;
		a[top] = x;

	} add {
		top++;
		a[top] = x;

	} top++ top a[top] = x a[top] a top x int x x int pop() {
		int x = a[top];
		top--;
		return x;
	} pop {
		int x = a[top];
		top--;
		return x;
	} int x = a[top]; x a[top] a top top-- top return x; x public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		String string = sc.nextLine();
		String[] a = string.split(" ");

		Poppin poppin = new Poppin(1000);

		for (int i = 0; i < a.length; i++) {

			if (a[i].equals("+")) {
				int p = poppin.pop();
				int q = poppin.pop();
				poppin.add(p + q);
				continue;

			}
			if (a[i].equals("-")) {

				int p = poppin.pop();
				int q = poppin.pop();
				poppin.add(q - p);
				continue;
			}
			if (a[i].equals("*")) {

				int p = poppin.pop();
				int q = poppin.pop();
				poppin.add(p * q);
				continue;
			}

			int n = Integer.parseInt(a[i]);
			poppin.add(n);

		}

		System.out.println(poppin.pop());

	}

} public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		String string = sc.nextLine();
		String[] a = string.split(" ");

		Poppin poppin = new Poppin(1000);

		for (int i = 0; i < a.length; i++) {

			if (a[i].equals("+")) {
				int p = poppin.pop();
				int q = poppin.pop();
				poppin.add(p + q);
				continue;

			}
			if (a[i].equals("-")) {

				int p = poppin.pop();
				int q = poppin.pop();
				poppin.add(q - p);
				continue;
			}
			if (a[i].equals("*")) {

				int p = poppin.pop();
				int q = poppin.pop();
				poppin.add(p * q);
				continue;
			}

			int n = Integer.parseInt(a[i]);
			poppin.add(n);

		}

		System.out.println(poppin.pop());

	}

} Main
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		String string = sc.nextLine();
		String[] a = string.split(" ");

		Poppin poppin = new Poppin(1000);

		for (int i = 0; i < a.length; i++) {

			if (a[i].equals("+")) {
				int p = poppin.pop();
				int q = poppin.pop();
				poppin.add(p + q);
				continue;

			}
			if (a[i].equals("-")) {

				int p = poppin.pop();
				int q = poppin.pop();
				poppin.add(q - p);
				continue;
			}
			if (a[i].equals("*")) {

				int p = poppin.pop();
				int q = poppin.pop();
				poppin.add(p * q);
				continue;
			}

			int n = Integer.parseInt(a[i]);
			poppin.add(n);

		}

		System.out.println(poppin.pop());

	}

}

class Poppin {
	int top = 0;
	int[] a;

	public Poppin(int n) {
		a = new int[n];
	}

	void add(int x) {
		top++;
		a[top] = x;

	}

	int pop() {
		int x = a[top];
		top--;
		return x;
	}
}