import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		int stack[] = new int[1000];

		Scanner scanner = new Scanner(System.in);
		int counta = 0;
		String input[] = (scanner.nextLine()).split(" ");

		for (int i = 0; i < input.length; i++) {
			if (input[i].equals("*")) {
				stack[counta - 2] = stack[counta - 2] * stack[counta - 1];
				counta--;
			} else if (input[i].equals("+")) {
				stack[counta - 2] = stack[counta - 2] + stack[counta - 1];
				counta--;

			} else if (input[i].equals("-")) {
				stack[counta - 2] = stack[counta - 2] - stack[counta - 1];
				counta--;

			} else {
				stack[counta] = Integer.parseInt(input[i]);
				counta++;
			}
		}
		System.out.println(stack[counta - 1]);
	}

} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
		int stack[] = new int[1000];

		Scanner scanner = new Scanner(System.in);
		int counta = 0;
		String input[] = (scanner.nextLine()).split(" ");

		for (int i = 0; i < input.length; i++) {
			if (input[i].equals("*")) {
				stack[counta - 2] = stack[counta - 2] * stack[counta - 1];
				counta--;
			} else if (input[i].equals("+")) {
				stack[counta - 2] = stack[counta - 2] + stack[counta - 1];
				counta--;

			} else if (input[i].equals("-")) {
				stack[counta - 2] = stack[counta - 2] - stack[counta - 1];
				counta--;

			} else {
				stack[counta] = Integer.parseInt(input[i]);
				counta++;
			}
		}
		System.out.println(stack[counta - 1]);
	}

} Main public static void main(String[] args) {
		int stack[] = new int[1000];

		Scanner scanner = new Scanner(System.in);
		int counta = 0;
		String input[] = (scanner.nextLine()).split(" ");

		for (int i = 0; i < input.length; i++) {
			if (input[i].equals("*")) {
				stack[counta - 2] = stack[counta - 2] * stack[counta - 1];
				counta--;
			} else if (input[i].equals("+")) {
				stack[counta - 2] = stack[counta - 2] + stack[counta - 1];
				counta--;

			} else if (input[i].equals("-")) {
				stack[counta - 2] = stack[counta - 2] - stack[counta - 1];
				counta--;

			} else {
				stack[counta] = Integer.parseInt(input[i]);
				counta++;
			}
		}
		System.out.println(stack[counta - 1]);
	} main {
		int stack[] = new int[1000];

		Scanner scanner = new Scanner(System.in);
		int counta = 0;
		String input[] = (scanner.nextLine()).split(" ");

		for (int i = 0; i < input.length; i++) {
			if (input[i].equals("*")) {
				stack[counta - 2] = stack[counta - 2] * stack[counta - 1];
				counta--;
			} else if (input[i].equals("+")) {
				stack[counta - 2] = stack[counta - 2] + stack[counta - 1];
				counta--;

			} else if (input[i].equals("-")) {
				stack[counta - 2] = stack[counta - 2] - stack[counta - 1];
				counta--;

			} else {
				stack[counta] = Integer.parseInt(input[i]);
				counta++;
			}
		}
		System.out.println(stack[counta - 1]);
	} int stack[] = new int[1000]; stack new int[1000] 1000 Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) int counta = 0; counta 0 String input[] = (scanner.nextLine()).split(" "); input (scanner.nextLine()).split(" ") (scanner.nextLine()).split (scanner.nextLine()) scanner.nextLine scanner " " for (int i = 0; i < input.length; i++) {
			if (input[i].equals("*")) {
				stack[counta - 2] = stack[counta - 2] * stack[counta - 1];
				counta--;
			} else if (input[i].equals("+")) {
				stack[counta - 2] = stack[counta - 2] + stack[counta - 1];
				counta--;

			} else if (input[i].equals("-")) {
				stack[counta - 2] = stack[counta - 2] - stack[counta - 1];
				counta--;

			} else {
				stack[counta] = Integer.parseInt(input[i]);
				counta++;
			}
		} int i = 0; int i = 0; i 0 i < input.length i input.length input input.length i++ i++ i {
			if (input[i].equals("*")) {
				stack[counta - 2] = stack[counta - 2] * stack[counta - 1];
				counta--;
			} else if (input[i].equals("+")) {
				stack[counta - 2] = stack[counta - 2] + stack[counta - 1];
				counta--;

			} else if (input[i].equals("-")) {
				stack[counta - 2] = stack[counta - 2] - stack[counta - 1];
				counta--;

			} else {
				stack[counta] = Integer.parseInt(input[i]);
				counta++;
			}
		} {
			if (input[i].equals("*")) {
				stack[counta - 2] = stack[counta - 2] * stack[counta - 1];
				counta--;
			} else if (input[i].equals("+")) {
				stack[counta - 2] = stack[counta - 2] + stack[counta - 1];
				counta--;

			} else if (input[i].equals("-")) {
				stack[counta - 2] = stack[counta - 2] - stack[counta - 1];
				counta--;

			} else {
				stack[counta] = Integer.parseInt(input[i]);
				counta++;
			}
		} if (input[i].equals("*")) {
				stack[counta - 2] = stack[counta - 2] * stack[counta - 1];
				counta--;
			} else if (input[i].equals("+")) {
				stack[counta - 2] = stack[counta - 2] + stack[counta - 1];
				counta--;

			} else if (input[i].equals("-")) {
				stack[counta - 2] = stack[counta - 2] - stack[counta - 1];
				counta--;

			} else {
				stack[counta] = Integer.parseInt(input[i]);
				counta++;
			} input[i].equals("*") input[i].equals input[i] input i "*" {
				stack[counta - 2] = stack[counta - 2] * stack[counta - 1];
				counta--;
			} stack[counta - 2] = stack[counta - 2] * stack[counta - 1] stack[counta - 2] stack counta - 2 counta 2 stack[counta - 2] * stack[counta - 1] stack[counta - 2] stack counta - 2 counta 2 stack[counta - 1] stack counta - 1 counta 1 counta-- counta if (input[i].equals("+")) {
				stack[counta - 2] = stack[counta - 2] + stack[counta - 1];
				counta--;

			} else if (input[i].equals("-")) {
				stack[counta - 2] = stack[counta - 2] - stack[counta - 1];
				counta--;

			} else {
				stack[counta] = Integer.parseInt(input[i]);
				counta++;
			} input[i].equals("+") input[i].equals input[i] input i "+" {
				stack[counta - 2] = stack[counta - 2] + stack[counta - 1];
				counta--;

			} stack[counta - 2] = stack[counta - 2] + stack[counta - 1] stack[counta - 2] stack counta - 2 counta 2 stack[counta - 2] + stack[counta - 1] stack[counta - 2] stack counta - 2 counta 2 stack[counta - 1] stack counta - 1 counta 1 counta-- counta if (input[i].equals("-")) {
				stack[counta - 2] = stack[counta - 2] - stack[counta - 1];
				counta--;

			} else {
				stack[counta] = Integer.parseInt(input[i]);
				counta++;
			} input[i].equals("-") input[i].equals input[i] input i "-" {
				stack[counta - 2] = stack[counta - 2] - stack[counta - 1];
				counta--;

			} stack[counta - 2] = stack[counta - 2] - stack[counta - 1] stack[counta - 2] stack counta - 2 counta 2 stack[counta - 2] - stack[counta - 1] stack[counta - 2] stack counta - 2 counta 2 stack[counta - 1] stack counta - 1 counta 1 counta-- counta {
				stack[counta] = Integer.parseInt(input[i]);
				counta++;
			} stack[counta] = Integer.parseInt(input[i]) stack[counta] stack counta Integer.parseInt(input[i]) Integer.parseInt Integer input[i] input i counta++ counta System.out.println(stack[counta - 1]) System.out.println System.out System System.out stack[counta - 1] stack counta - 1 counta 1 String[] args args public class Main {
	public static void main(String[] args) {
		int stack[] = new int[1000];

		Scanner scanner = new Scanner(System.in);
		int counta = 0;
		String input[] = (scanner.nextLine()).split(" ");

		for (int i = 0; i < input.length; i++) {
			if (input[i].equals("*")) {
				stack[counta - 2] = stack[counta - 2] * stack[counta - 1];
				counta--;
			} else if (input[i].equals("+")) {
				stack[counta - 2] = stack[counta - 2] + stack[counta - 1];
				counta--;

			} else if (input[i].equals("-")) {
				stack[counta - 2] = stack[counta - 2] - stack[counta - 1];
				counta--;

			} else {
				stack[counta] = Integer.parseInt(input[i]);
				counta++;
			}
		}
		System.out.println(stack[counta - 1]);
	}

} public class Main {
	public static void main(String[] args) {
		int stack[] = new int[1000];

		Scanner scanner = new Scanner(System.in);
		int counta = 0;
		String input[] = (scanner.nextLine()).split(" ");

		for (int i = 0; i < input.length; i++) {
			if (input[i].equals("*")) {
				stack[counta - 2] = stack[counta - 2] * stack[counta - 1];
				counta--;
			} else if (input[i].equals("+")) {
				stack[counta - 2] = stack[counta - 2] + stack[counta - 1];
				counta--;

			} else if (input[i].equals("-")) {
				stack[counta - 2] = stack[counta - 2] - stack[counta - 1];
				counta--;

			} else {
				stack[counta] = Integer.parseInt(input[i]);
				counta++;
			}
		}
		System.out.println(stack[counta - 1]);
	}

} Main
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		int stack[] = new int[1000];

		Scanner scanner = new Scanner(System.in);
		int counta = 0;
		String input[] = (scanner.nextLine()).split(" ");

		for (int i = 0; i < input.length; i++) {
			if (input[i].equals("*")) {
				stack[counta - 2] = stack[counta - 2] * stack[counta - 1];
				counta--;
			} else if (input[i].equals("+")) {
				stack[counta - 2] = stack[counta - 2] + stack[counta - 1];
				counta--;

			} else if (input[i].equals("-")) {
				stack[counta - 2] = stack[counta - 2] - stack[counta - 1];
				counta--;

			} else {
				stack[counta] = Integer.parseInt(input[i]);
				counta++;
			}
		}
		System.out.println(stack[counta - 1]);
	}

}
