import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String[] ary =  br.readLine().split(" ");
		int[] stack = new int[ary.length];
		int stackCount = -1;
		for(int i = 0 ; i < ary.length ; i++){
			if(ary[i].equals("+")){
				stack[stackCount - 1] = stack[stackCount - 1] + stack[stackCount];
				stackCount--;
			}else if(ary[i].equals("-")){
				stack[stackCount - 1] = stack[stackCount - 1] - stack[stackCount];
				stackCount--;
			}else if(ary[i].equals("*")){
				stack[stackCount - 1] = stack[stackCount - 1] * stack[stackCount];
				stackCount--;
			}else{
				stack[++stackCount] = Integer.parseInt(ary[i]);
			}
		}

		System.out.println(stack[stackCount]);
	}

} import java.io.BufferedReader; BufferedReader java.io import java.io.InputStreamReader; InputStreamReader java.io public class Main {

	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String[] ary =  br.readLine().split(" ");
		int[] stack = new int[ary.length];
		int stackCount = -1;
		for(int i = 0 ; i < ary.length ; i++){
			if(ary[i].equals("+")){
				stack[stackCount - 1] = stack[stackCount - 1] + stack[stackCount];
				stackCount--;
			}else if(ary[i].equals("-")){
				stack[stackCount - 1] = stack[stackCount - 1] - stack[stackCount];
				stackCount--;
			}else if(ary[i].equals("*")){
				stack[stackCount - 1] = stack[stackCount - 1] * stack[stackCount];
				stackCount--;
			}else{
				stack[++stackCount] = Integer.parseInt(ary[i]);
			}
		}

		System.out.println(stack[stackCount]);
	}

} Main public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String[] ary =  br.readLine().split(" ");
		int[] stack = new int[ary.length];
		int stackCount = -1;
		for(int i = 0 ; i < ary.length ; i++){
			if(ary[i].equals("+")){
				stack[stackCount - 1] = stack[stackCount - 1] + stack[stackCount];
				stackCount--;
			}else if(ary[i].equals("-")){
				stack[stackCount - 1] = stack[stackCount - 1] - stack[stackCount];
				stackCount--;
			}else if(ary[i].equals("*")){
				stack[stackCount - 1] = stack[stackCount - 1] * stack[stackCount];
				stackCount--;
			}else{
				stack[++stackCount] = Integer.parseInt(ary[i]);
			}
		}

		System.out.println(stack[stackCount]);
	} main {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String[] ary =  br.readLine().split(" ");
		int[] stack = new int[ary.length];
		int stackCount = -1;
		for(int i = 0 ; i < ary.length ; i++){
			if(ary[i].equals("+")){
				stack[stackCount - 1] = stack[stackCount - 1] + stack[stackCount];
				stackCount--;
			}else if(ary[i].equals("-")){
				stack[stackCount - 1] = stack[stackCount - 1] - stack[stackCount];
				stackCount--;
			}else if(ary[i].equals("*")){
				stack[stackCount - 1] = stack[stackCount - 1] * stack[stackCount];
				stackCount--;
			}else{
				stack[++stackCount] = Integer.parseInt(ary[i]);
			}
		}

		System.out.println(stack[stackCount]);
	} BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) String[] ary =  br.readLine().split(" "); ary br.readLine().split(" ") br.readLine().split br.readLine() br.readLine br " " int[] stack = new int[ary.length]; stack new int[ary.length] ary.length ary ary.length int stackCount = -1; stackCount -1 1 for(int i = 0 ; i < ary.length ; i++){
			if(ary[i].equals("+")){
				stack[stackCount - 1] = stack[stackCount - 1] + stack[stackCount];
				stackCount--;
			}else if(ary[i].equals("-")){
				stack[stackCount - 1] = stack[stackCount - 1] - stack[stackCount];
				stackCount--;
			}else if(ary[i].equals("*")){
				stack[stackCount - 1] = stack[stackCount - 1] * stack[stackCount];
				stackCount--;
			}else{
				stack[++stackCount] = Integer.parseInt(ary[i]);
			}
		} int i = 0 ; int i = 0 ; i 0 i < ary.length i ary.length ary ary.length i++ i++ i {
			if(ary[i].equals("+")){
				stack[stackCount - 1] = stack[stackCount - 1] + stack[stackCount];
				stackCount--;
			}else if(ary[i].equals("-")){
				stack[stackCount - 1] = stack[stackCount - 1] - stack[stackCount];
				stackCount--;
			}else if(ary[i].equals("*")){
				stack[stackCount - 1] = stack[stackCount - 1] * stack[stackCount];
				stackCount--;
			}else{
				stack[++stackCount] = Integer.parseInt(ary[i]);
			}
		} {
			if(ary[i].equals("+")){
				stack[stackCount - 1] = stack[stackCount - 1] + stack[stackCount];
				stackCount--;
			}else if(ary[i].equals("-")){
				stack[stackCount - 1] = stack[stackCount - 1] - stack[stackCount];
				stackCount--;
			}else if(ary[i].equals("*")){
				stack[stackCount - 1] = stack[stackCount - 1] * stack[stackCount];
				stackCount--;
			}else{
				stack[++stackCount] = Integer.parseInt(ary[i]);
			}
		} if(ary[i].equals("+")){
				stack[stackCount - 1] = stack[stackCount - 1] + stack[stackCount];
				stackCount--;
			}else if(ary[i].equals("-")){
				stack[stackCount - 1] = stack[stackCount - 1] - stack[stackCount];
				stackCount--;
			}else if(ary[i].equals("*")){
				stack[stackCount - 1] = stack[stackCount - 1] * stack[stackCount];
				stackCount--;
			}else{
				stack[++stackCount] = Integer.parseInt(ary[i]);
			} ary[i].equals("+") ary[i].equals ary[i] ary i "+" {
				stack[stackCount - 1] = stack[stackCount - 1] + stack[stackCount];
				stackCount--;
			} stack[stackCount - 1] = stack[stackCount - 1] + stack[stackCount] stack[stackCount - 1] stack stackCount - 1 stackCount 1 stack[stackCount - 1] + stack[stackCount] stack[stackCount - 1] stack stackCount - 1 stackCount 1 stack[stackCount] stack stackCount stackCount-- stackCount if(ary[i].equals("-")){
				stack[stackCount - 1] = stack[stackCount - 1] - stack[stackCount];
				stackCount--;
			}else if(ary[i].equals("*")){
				stack[stackCount - 1] = stack[stackCount - 1] * stack[stackCount];
				stackCount--;
			}else{
				stack[++stackCount] = Integer.parseInt(ary[i]);
			} ary[i].equals("-") ary[i].equals ary[i] ary i "-" {
				stack[stackCount - 1] = stack[stackCount - 1] - stack[stackCount];
				stackCount--;
			} stack[stackCount - 1] = stack[stackCount - 1] - stack[stackCount] stack[stackCount - 1] stack stackCount - 1 stackCount 1 stack[stackCount - 1] - stack[stackCount] stack[stackCount - 1] stack stackCount - 1 stackCount 1 stack[stackCount] stack stackCount stackCount-- stackCount if(ary[i].equals("*")){
				stack[stackCount - 1] = stack[stackCount - 1] * stack[stackCount];
				stackCount--;
			}else{
				stack[++stackCount] = Integer.parseInt(ary[i]);
			} ary[i].equals("*") ary[i].equals ary[i] ary i "*" {
				stack[stackCount - 1] = stack[stackCount - 1] * stack[stackCount];
				stackCount--;
			} stack[stackCount - 1] = stack[stackCount - 1] * stack[stackCount] stack[stackCount - 1] stack stackCount - 1 stackCount 1 stack[stackCount - 1] * stack[stackCount] stack[stackCount - 1] stack stackCount - 1 stackCount 1 stack[stackCount] stack stackCount stackCount-- stackCount {
				stack[++stackCount] = Integer.parseInt(ary[i]);
			} stack[++stackCount] = Integer.parseInt(ary[i]) stack[++stackCount] stack ++stackCount stackCount Integer.parseInt(ary[i]) Integer.parseInt Integer ary[i] ary i System.out.println(stack[stackCount]) System.out.println System.out System System.out stack[stackCount] stack stackCount String[] args args public class Main {

	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String[] ary =  br.readLine().split(" ");
		int[] stack = new int[ary.length];
		int stackCount = -1;
		for(int i = 0 ; i < ary.length ; i++){
			if(ary[i].equals("+")){
				stack[stackCount - 1] = stack[stackCount - 1] + stack[stackCount];
				stackCount--;
			}else if(ary[i].equals("-")){
				stack[stackCount - 1] = stack[stackCount - 1] - stack[stackCount];
				stackCount--;
			}else if(ary[i].equals("*")){
				stack[stackCount - 1] = stack[stackCount - 1] * stack[stackCount];
				stackCount--;
			}else{
				stack[++stackCount] = Integer.parseInt(ary[i]);
			}
		}

		System.out.println(stack[stackCount]);
	}

} public class Main {

	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String[] ary =  br.readLine().split(" ");
		int[] stack = new int[ary.length];
		int stackCount = -1;
		for(int i = 0 ; i < ary.length ; i++){
			if(ary[i].equals("+")){
				stack[stackCount - 1] = stack[stackCount - 1] + stack[stackCount];
				stackCount--;
			}else if(ary[i].equals("-")){
				stack[stackCount - 1] = stack[stackCount - 1] - stack[stackCount];
				stackCount--;
			}else if(ary[i].equals("*")){
				stack[stackCount - 1] = stack[stackCount - 1] * stack[stackCount];
				stackCount--;
			}else{
				stack[++stackCount] = Integer.parseInt(ary[i]);
			}
		}

		System.out.println(stack[stackCount]);
	}

} Main
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String[] ary =  br.readLine().split(" ");
		int[] stack = new int[ary.length];
		int stackCount = -1;
		for(int i = 0 ; i < ary.length ; i++){
			if(ary[i].equals("+")){
				stack[stackCount - 1] = stack[stackCount - 1] + stack[stackCount];
				stackCount--;
			}else if(ary[i].equals("-")){
				stack[stackCount - 1] = stack[stackCount - 1] - stack[stackCount];
				stackCount--;
			}else if(ary[i].equals("*")){
				stack[stackCount - 1] = stack[stackCount - 1] * stack[stackCount];
				stackCount--;
			}else{
				stack[++stackCount] = Integer.parseInt(ary[i]);
			}
		}

		System.out.println(stack[stackCount]);
	}

}