import java.util.*;

public class Main{
	final static int MOD = 1000000007;
	final static int INF = 1000000000;

	public static void main(String[] args){
		Deque<Integer> S = new ArrayDeque<Integer>();
		Scanner sc = new Scanner(System.in);
		String line = sc.nextLine();
		String[] str = line.split(" ");
		for(String s : str){
			if(s.equals(""))
				break;
			if(s.equals("+")){
				int b = S.pop();
				int a = S.pop();
				S.push(a + b);
//				System.out.printf("%d + %d = %d\n", a, b, a+b);
			}else if(s.equals("-")){
				int b = S.pop();
				int a = S.pop();
				S.push(a - b);
//				System.out.printf("%d - %d = %d\n", a, b, a - b);
			}else if(s.equals("*")){
				int b = S.pop();
				int a = S.pop();
				S.push(a * b);
//				System.out.printf("%d * %d = %d\n", a, b, a * b);
			}else{
				S.push(Integer.parseInt(s));
//				System.out.printf("insert %d\n", Integer.parseInt(s));
			}
//			System.out.println(S);
		}
		sc.close();
		System.out.println(S.getFirst().intValue());

	}

} import java.util.*; util.* java public class Main{
	final static int MOD = 1000000007;
	final static int INF = 1000000000;

	public static void main(String[] args){
		Deque<Integer> S = new ArrayDeque<Integer>();
		Scanner sc = new Scanner(System.in);
		String line = sc.nextLine();
		String[] str = line.split(" ");
		for(String s : str){
			if(s.equals(""))
				break;
			if(s.equals("+")){
				int b = S.pop();
				int a = S.pop();
				S.push(a + b);
//				System.out.printf("%d + %d = %d\n", a, b, a+b);
			}else if(s.equals("-")){
				int b = S.pop();
				int a = S.pop();
				S.push(a - b);
//				System.out.printf("%d - %d = %d\n", a, b, a - b);
			}else if(s.equals("*")){
				int b = S.pop();
				int a = S.pop();
				S.push(a * b);
//				System.out.printf("%d * %d = %d\n", a, b, a * b);
			}else{
				S.push(Integer.parseInt(s));
//				System.out.printf("insert %d\n", Integer.parseInt(s));
			}
//			System.out.println(S);
		}
		sc.close();
		System.out.println(S.getFirst().intValue());

	}

} Main final static int MOD = 1000000007; MOD 1000000007 final static int INF = 1000000000; INF 1000000000 public static void main(String[] args){
		Deque<Integer> S = new ArrayDeque<Integer>();
		Scanner sc = new Scanner(System.in);
		String line = sc.nextLine();
		String[] str = line.split(" ");
		for(String s : str){
			if(s.equals(""))
				break;
			if(s.equals("+")){
				int b = S.pop();
				int a = S.pop();
				S.push(a + b);
//				System.out.printf("%d + %d = %d\n", a, b, a+b);
			}else if(s.equals("-")){
				int b = S.pop();
				int a = S.pop();
				S.push(a - b);
//				System.out.printf("%d - %d = %d\n", a, b, a - b);
			}else if(s.equals("*")){
				int b = S.pop();
				int a = S.pop();
				S.push(a * b);
//				System.out.printf("%d * %d = %d\n", a, b, a * b);
			}else{
				S.push(Integer.parseInt(s));
//				System.out.printf("insert %d\n", Integer.parseInt(s));
			}
//			System.out.println(S);
		}
		sc.close();
		System.out.println(S.getFirst().intValue());

	} main {
		Deque<Integer> S = new ArrayDeque<Integer>();
		Scanner sc = new Scanner(System.in);
		String line = sc.nextLine();
		String[] str = line.split(" ");
		for(String s : str){
			if(s.equals(""))
				break;
			if(s.equals("+")){
				int b = S.pop();
				int a = S.pop();
				S.push(a + b);
//				System.out.printf("%d + %d = %d\n", a, b, a+b);
			}else if(s.equals("-")){
				int b = S.pop();
				int a = S.pop();
				S.push(a - b);
//				System.out.printf("%d - %d = %d\n", a, b, a - b);
			}else if(s.equals("*")){
				int b = S.pop();
				int a = S.pop();
				S.push(a * b);
//				System.out.printf("%d * %d = %d\n", a, b, a * b);
			}else{
				S.push(Integer.parseInt(s));
//				System.out.printf("insert %d\n", Integer.parseInt(s));
			}
//			System.out.println(S);
		}
		sc.close();
		System.out.println(S.getFirst().intValue());

	} Deque<Integer> S = new ArrayDeque<Integer>(); S new ArrayDeque<Integer>() Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String line = sc.nextLine(); line sc.nextLine() sc.nextLine sc String[] str = line.split(" "); str line.split(" ") line.split line " " for(String s : str){
			if(s.equals(""))
				break;
			if(s.equals("+")){
				int b = S.pop();
				int a = S.pop();
				S.push(a + b);
//				System.out.printf("%d + %d = %d\n", a, b, a+b);
			}else if(s.equals("-")){
				int b = S.pop();
				int a = S.pop();
				S.push(a - b);
//				System.out.printf("%d - %d = %d\n", a, b, a - b);
			}else if(s.equals("*")){
				int b = S.pop();
				int a = S.pop();
				S.push(a * b);
//				System.out.printf("%d * %d = %d\n", a, b, a * b);
			}else{
				S.push(Integer.parseInt(s));
//				System.out.printf("insert %d\n", Integer.parseInt(s));
			}
//			System.out.println(S);
		} String s str {
			if(s.equals(""))
				break;
			if(s.equals("+")){
				int b = S.pop();
				int a = S.pop();
				S.push(a + b);
//				System.out.printf("%d + %d = %d\n", a, b, a+b);
			}else if(s.equals("-")){
				int b = S.pop();
				int a = S.pop();
				S.push(a - b);
//				System.out.printf("%d - %d = %d\n", a, b, a - b);
			}else if(s.equals("*")){
				int b = S.pop();
				int a = S.pop();
				S.push(a * b);
//				System.out.printf("%d * %d = %d\n", a, b, a * b);
			}else{
				S.push(Integer.parseInt(s));
//				System.out.printf("insert %d\n", Integer.parseInt(s));
			}
//			System.out.println(S);
		} {
			if(s.equals(""))
				break;
			if(s.equals("+")){
				int b = S.pop();
				int a = S.pop();
				S.push(a + b);
//				System.out.printf("%d + %d = %d\n", a, b, a+b);
			}else if(s.equals("-")){
				int b = S.pop();
				int a = S.pop();
				S.push(a - b);
//				System.out.printf("%d - %d = %d\n", a, b, a - b);
			}else if(s.equals("*")){
				int b = S.pop();
				int a = S.pop();
				S.push(a * b);
//				System.out.printf("%d * %d = %d\n", a, b, a * b);
			}else{
				S.push(Integer.parseInt(s));
//				System.out.printf("insert %d\n", Integer.parseInt(s));
			}
//			System.out.println(S);
		} if(s.equals(""))
				break; s.equals("") s.equals s "" break; if(s.equals("+")){
				int b = S.pop();
				int a = S.pop();
				S.push(a + b);
//				System.out.printf("%d + %d = %d\n", a, b, a+b);
			}else if(s.equals("-")){
				int b = S.pop();
				int a = S.pop();
				S.push(a - b);
//				System.out.printf("%d - %d = %d\n", a, b, a - b);
			}else if(s.equals("*")){
				int b = S.pop();
				int a = S.pop();
				S.push(a * b);
//				System.out.printf("%d * %d = %d\n", a, b, a * b);
			}else{
				S.push(Integer.parseInt(s));
//				System.out.printf("insert %d\n", Integer.parseInt(s));
			} s.equals("+") s.equals s "+" {
				int b = S.pop();
				int a = S.pop();
				S.push(a + b);
//				System.out.printf("%d + %d = %d\n", a, b, a+b);
			} int b = S.pop(); b S.pop() S.pop S int a = S.pop(); a S.pop() S.pop S S.push(a + b) S.push S a + b a b if(s.equals("-")){
				int b = S.pop();
				int a = S.pop();
				S.push(a - b);
//				System.out.printf("%d - %d = %d\n", a, b, a - b);
			}else if(s.equals("*")){
				int b = S.pop();
				int a = S.pop();
				S.push(a * b);
//				System.out.printf("%d * %d = %d\n", a, b, a * b);
			}else{
				S.push(Integer.parseInt(s));
//				System.out.printf("insert %d\n", Integer.parseInt(s));
			} s.equals("-") s.equals s "-" {
				int b = S.pop();
				int a = S.pop();
				S.push(a - b);
//				System.out.printf("%d - %d = %d\n", a, b, a - b);
			} int b = S.pop(); b S.pop() S.pop S int a = S.pop(); a S.pop() S.pop S S.push(a - b) S.push S a - b a b if(s.equals("*")){
				int b = S.pop();
				int a = S.pop();
				S.push(a * b);
//				System.out.printf("%d * %d = %d\n", a, b, a * b);
			}else{
				S.push(Integer.parseInt(s));
//				System.out.printf("insert %d\n", Integer.parseInt(s));
			} s.equals("*") s.equals s "*" {
				int b = S.pop();
				int a = S.pop();
				S.push(a * b);
//				System.out.printf("%d * %d = %d\n", a, b, a * b);
			} int b = S.pop(); b S.pop() S.pop S int a = S.pop(); a S.pop() S.pop S S.push(a * b) S.push S a * b a b {
				S.push(Integer.parseInt(s));
//				System.out.printf("insert %d\n", Integer.parseInt(s));
			} S.push(Integer.parseInt(s)) S.push S Integer.parseInt(s) Integer.parseInt Integer s sc.close() sc.close sc System.out.println(S.getFirst().intValue()) System.out.println System.out System System.out S.getFirst().intValue() S.getFirst().intValue S.getFirst() S.getFirst S String[] args args public class Main{
	final static int MOD = 1000000007;
	final static int INF = 1000000000;

	public static void main(String[] args){
		Deque<Integer> S = new ArrayDeque<Integer>();
		Scanner sc = new Scanner(System.in);
		String line = sc.nextLine();
		String[] str = line.split(" ");
		for(String s : str){
			if(s.equals(""))
				break;
			if(s.equals("+")){
				int b = S.pop();
				int a = S.pop();
				S.push(a + b);
//				System.out.printf("%d + %d = %d\n", a, b, a+b);
			}else if(s.equals("-")){
				int b = S.pop();
				int a = S.pop();
				S.push(a - b);
//				System.out.printf("%d - %d = %d\n", a, b, a - b);
			}else if(s.equals("*")){
				int b = S.pop();
				int a = S.pop();
				S.push(a * b);
//				System.out.printf("%d * %d = %d\n", a, b, a * b);
			}else{
				S.push(Integer.parseInt(s));
//				System.out.printf("insert %d\n", Integer.parseInt(s));
			}
//			System.out.println(S);
		}
		sc.close();
		System.out.println(S.getFirst().intValue());

	}

} public class Main{
	final static int MOD = 1000000007;
	final static int INF = 1000000000;

	public static void main(String[] args){
		Deque<Integer> S = new ArrayDeque<Integer>();
		Scanner sc = new Scanner(System.in);
		String line = sc.nextLine();
		String[] str = line.split(" ");
		for(String s : str){
			if(s.equals(""))
				break;
			if(s.equals("+")){
				int b = S.pop();
				int a = S.pop();
				S.push(a + b);
//				System.out.printf("%d + %d = %d\n", a, b, a+b);
			}else if(s.equals("-")){
				int b = S.pop();
				int a = S.pop();
				S.push(a - b);
//				System.out.printf("%d - %d = %d\n", a, b, a - b);
			}else if(s.equals("*")){
				int b = S.pop();
				int a = S.pop();
				S.push(a * b);
//				System.out.printf("%d * %d = %d\n", a, b, a * b);
			}else{
				S.push(Integer.parseInt(s));
//				System.out.printf("insert %d\n", Integer.parseInt(s));
			}
//			System.out.println(S);
		}
		sc.close();
		System.out.println(S.getFirst().intValue());

	}

} Main
import java.util.*;

public class Main{
	final static int MOD = 1000000007;
	final static int INF = 1000000000;

	public static void main(String[] args){
		Deque<Integer> S = new ArrayDeque<Integer>();
		Scanner sc = new Scanner(System.in);
		String line = sc.nextLine();
		String[] str = line.split(" ");
		for(String s : str){
			if(s.equals(""))
				break;
			if(s.equals("+")){
				int b = S.pop();
				int a = S.pop();
				S.push(a + b);
//				System.out.printf("%d + %d = %d\n", a, b, a+b);
			}else if(s.equals("-")){
				int b = S.pop();
				int a = S.pop();
				S.push(a - b);
//				System.out.printf("%d - %d = %d\n", a, b, a - b);
			}else if(s.equals("*")){
				int b = S.pop();
				int a = S.pop();
				S.push(a * b);
//				System.out.printf("%d * %d = %d\n", a, b, a * b);
			}else{
				S.push(Integer.parseInt(s));
//				System.out.printf("insert %d\n", Integer.parseInt(s));
			}
//			System.out.println(S);
		}
		sc.close();
		System.out.println(S.getFirst().intValue());

	}

}
