import java.io.*;
import java.util.*;

public class Main {
	public static void main(String[] args) throws NumberFormatException, IOException{
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		PrintWriter pr=new PrintWriter(System.out);
		String str[]=br.readLine().split(" ");
		Deque<Integer> stack=new ArrayDeque<Integer>();
		int a,b;
		for (int i=0;i<str.length;i++){
			switch(str[i]){
			case "+":
				a=stack.pop();
				b=stack.pop();
				stack.push(b+a);
				break;
			case "-":
				a=stack.pop();
				b=stack.pop();
				stack.push(b-a);
				break;
			case "*":
				a=stack.pop();
				b=stack.pop();
				stack.push(b*a);
				break;
			default:
				stack.push(Integer.parseInt(str[i]));
				break;
			}
		}
		pr.println(stack.pop());
		pr.close();
	}

} import java.io.*; io.* java import java.util.*; util.* java public class Main {
	public static void main(String[] args) throws NumberFormatException, IOException{
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		PrintWriter pr=new PrintWriter(System.out);
		String str[]=br.readLine().split(" ");
		Deque<Integer> stack=new ArrayDeque<Integer>();
		int a,b;
		for (int i=0;i<str.length;i++){
			switch(str[i]){
			case "+":
				a=stack.pop();
				b=stack.pop();
				stack.push(b+a);
				break;
			case "-":
				a=stack.pop();
				b=stack.pop();
				stack.push(b-a);
				break;
			case "*":
				a=stack.pop();
				b=stack.pop();
				stack.push(b*a);
				break;
			default:
				stack.push(Integer.parseInt(str[i]));
				break;
			}
		}
		pr.println(stack.pop());
		pr.close();
	}

} Main public static void main(String[] args) throws NumberFormatException, IOException{
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		PrintWriter pr=new PrintWriter(System.out);
		String str[]=br.readLine().split(" ");
		Deque<Integer> stack=new ArrayDeque<Integer>();
		int a,b;
		for (int i=0;i<str.length;i++){
			switch(str[i]){
			case "+":
				a=stack.pop();
				b=stack.pop();
				stack.push(b+a);
				break;
			case "-":
				a=stack.pop();
				b=stack.pop();
				stack.push(b-a);
				break;
			case "*":
				a=stack.pop();
				b=stack.pop();
				stack.push(b*a);
				break;
			default:
				stack.push(Integer.parseInt(str[i]));
				break;
			}
		}
		pr.println(stack.pop());
		pr.close();
	} main {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		PrintWriter pr=new PrintWriter(System.out);
		String str[]=br.readLine().split(" ");
		Deque<Integer> stack=new ArrayDeque<Integer>();
		int a,b;
		for (int i=0;i<str.length;i++){
			switch(str[i]){
			case "+":
				a=stack.pop();
				b=stack.pop();
				stack.push(b+a);
				break;
			case "-":
				a=stack.pop();
				b=stack.pop();
				stack.push(b-a);
				break;
			case "*":
				a=stack.pop();
				b=stack.pop();
				stack.push(b*a);
				break;
			default:
				stack.push(Integer.parseInt(str[i]));
				break;
			}
		}
		pr.println(stack.pop());
		pr.close();
	} BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) PrintWriter pr=new PrintWriter(System.out); pr new PrintWriter(System.out) String str[]=br.readLine().split(" "); str br.readLine().split(" ") br.readLine().split br.readLine() br.readLine br " " Deque<Integer> stack=new ArrayDeque<Integer>(); stack new ArrayDeque<Integer>() int a a b; b for (int i=0;i<str.length;i++){
			switch(str[i]){
			case "+":
				a=stack.pop();
				b=stack.pop();
				stack.push(b+a);
				break;
			case "-":
				a=stack.pop();
				b=stack.pop();
				stack.push(b-a);
				break;
			case "*":
				a=stack.pop();
				b=stack.pop();
				stack.push(b*a);
				break;
			default:
				stack.push(Integer.parseInt(str[i]));
				break;
			}
		} int i=0; int i=0; i 0 i<str.length i str.length str str.length i++ i++ i {
			switch(str[i]){
			case "+":
				a=stack.pop();
				b=stack.pop();
				stack.push(b+a);
				break;
			case "-":
				a=stack.pop();
				b=stack.pop();
				stack.push(b-a);
				break;
			case "*":
				a=stack.pop();
				b=stack.pop();
				stack.push(b*a);
				break;
			default:
				stack.push(Integer.parseInt(str[i]));
				break;
			}
		} {
			switch(str[i]){
			case "+":
				a=stack.pop();
				b=stack.pop();
				stack.push(b+a);
				break;
			case "-":
				a=stack.pop();
				b=stack.pop();
				stack.push(b-a);
				break;
			case "*":
				a=stack.pop();
				b=stack.pop();
				stack.push(b*a);
				break;
			default:
				stack.push(Integer.parseInt(str[i]));
				break;
			}
		} switch(str[i]){
			case "+":
				a=stack.pop();
				b=stack.pop();
				stack.push(b+a);
				break;
			case "-":
				a=stack.pop();
				b=stack.pop();
				stack.push(b-a);
				break;
			case "*":
				a=stack.pop();
				b=stack.pop();
				stack.push(b*a);
				break;
			default:
				stack.push(Integer.parseInt(str[i]));
				break;
			} str[i] str i case "+": "+" case "+": a=stack.pop() a stack.pop() stack.pop stack b=stack.pop() b stack.pop() stack.pop stack stack.push(b+a) stack.push stack b+a b a break; case "-": "-" case "-": a=stack.pop() a stack.pop() stack.pop stack b=stack.pop() b stack.pop() stack.pop stack stack.push(b-a) stack.push stack b-a b a break; case "*": "*" case "*": a=stack.pop() a stack.pop() stack.pop stack b=stack.pop() b stack.pop() stack.pop stack stack.push(b*a) stack.push stack b*a b a break; default: default: stack.push(Integer.parseInt(str[i])) stack.push stack Integer.parseInt(str[i]) Integer.parseInt Integer str[i] str i break; pr.println(stack.pop()) pr.println pr stack.pop() stack.pop stack pr.close() pr.close pr String[] args args public class Main {
	public static void main(String[] args) throws NumberFormatException, IOException{
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		PrintWriter pr=new PrintWriter(System.out);
		String str[]=br.readLine().split(" ");
		Deque<Integer> stack=new ArrayDeque<Integer>();
		int a,b;
		for (int i=0;i<str.length;i++){
			switch(str[i]){
			case "+":
				a=stack.pop();
				b=stack.pop();
				stack.push(b+a);
				break;
			case "-":
				a=stack.pop();
				b=stack.pop();
				stack.push(b-a);
				break;
			case "*":
				a=stack.pop();
				b=stack.pop();
				stack.push(b*a);
				break;
			default:
				stack.push(Integer.parseInt(str[i]));
				break;
			}
		}
		pr.println(stack.pop());
		pr.close();
	}

} public class Main {
	public static void main(String[] args) throws NumberFormatException, IOException{
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		PrintWriter pr=new PrintWriter(System.out);
		String str[]=br.readLine().split(" ");
		Deque<Integer> stack=new ArrayDeque<Integer>();
		int a,b;
		for (int i=0;i<str.length;i++){
			switch(str[i]){
			case "+":
				a=stack.pop();
				b=stack.pop();
				stack.push(b+a);
				break;
			case "-":
				a=stack.pop();
				b=stack.pop();
				stack.push(b-a);
				break;
			case "*":
				a=stack.pop();
				b=stack.pop();
				stack.push(b*a);
				break;
			default:
				stack.push(Integer.parseInt(str[i]));
				break;
			}
		}
		pr.println(stack.pop());
		pr.close();
	}

} Main
import java.io.*;
import java.util.*;

public class Main {
	public static void main(String[] args) throws NumberFormatException, IOException{
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		PrintWriter pr=new PrintWriter(System.out);
		String str[]=br.readLine().split(" ");
		Deque<Integer> stack=new ArrayDeque<Integer>();
		int a,b;
		for (int i=0;i<str.length;i++){
			switch(str[i]){
			case "+":
				a=stack.pop();
				b=stack.pop();
				stack.push(b+a);
				break;
			case "-":
				a=stack.pop();
				b=stack.pop();
				stack.push(b-a);
				break;
			case "*":
				a=stack.pop();
				b=stack.pop();
				stack.push(b*a);
				break;
			default:
				stack.push(Integer.parseInt(str[i]));
				break;
			}
		}
		pr.println(stack.pop());
		pr.close();
	}

}