import java.util.Scanner;
import java.util.Stack;

public class Main {
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)){
			Stack<String> stack=new Stack<String>();
			String s=sc.nextLine();
			String[] token=s.split(" ");
			for(String t:token) {
				if(t.equals("+") || t.equals("-") || t.equals("*")){ 
					int num1=Integer.valueOf((String) stack.pop());
					int num2=Integer.valueOf((String) stack.pop());
					if(t.equals("+")) {
						stack.push(String.valueOf(num1+num2));
					}
					else if(t.equals("-")) {
						stack.push(String.valueOf(num2-num1));
					}
					else {
						stack.push(String.valueOf(num1*num2));
					}
					
				}
				else {
					stack.push(t);
				}
			}
			System.out.println(stack.pop());

		}
	}
} import java.util.Scanner; Scanner java.util import java.util.Stack; Stack java.util public class Main {
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)){
			Stack<String> stack=new Stack<String>();
			String s=sc.nextLine();
			String[] token=s.split(" ");
			for(String t:token) {
				if(t.equals("+") || t.equals("-") || t.equals("*")){ 
					int num1=Integer.valueOf((String) stack.pop());
					int num2=Integer.valueOf((String) stack.pop());
					if(t.equals("+")) {
						stack.push(String.valueOf(num1+num2));
					}
					else if(t.equals("-")) {
						stack.push(String.valueOf(num2-num1));
					}
					else {
						stack.push(String.valueOf(num1*num2));
					}
					
				}
				else {
					stack.push(t);
				}
			}
			System.out.println(stack.pop());

		}
	}
} Main public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)){
			Stack<String> stack=new Stack<String>();
			String s=sc.nextLine();
			String[] token=s.split(" ");
			for(String t:token) {
				if(t.equals("+") || t.equals("-") || t.equals("*")){ 
					int num1=Integer.valueOf((String) stack.pop());
					int num2=Integer.valueOf((String) stack.pop());
					if(t.equals("+")) {
						stack.push(String.valueOf(num1+num2));
					}
					else if(t.equals("-")) {
						stack.push(String.valueOf(num2-num1));
					}
					else {
						stack.push(String.valueOf(num1*num2));
					}
					
				}
				else {
					stack.push(t);
				}
			}
			System.out.println(stack.pop());

		}
	} main {
		try(Scanner sc = new Scanner(System.in)){
			Stack<String> stack=new Stack<String>();
			String s=sc.nextLine();
			String[] token=s.split(" ");
			for(String t:token) {
				if(t.equals("+") || t.equals("-") || t.equals("*")){ 
					int num1=Integer.valueOf((String) stack.pop());
					int num2=Integer.valueOf((String) stack.pop());
					if(t.equals("+")) {
						stack.push(String.valueOf(num1+num2));
					}
					else if(t.equals("-")) {
						stack.push(String.valueOf(num2-num1));
					}
					else {
						stack.push(String.valueOf(num1*num2));
					}
					
				}
				else {
					stack.push(t);
				}
			}
			System.out.println(stack.pop());

		}
	} try(Scanner sc = new Scanner(System.in)){
			Stack<String> stack=new Stack<String>();
			String s=sc.nextLine();
			String[] token=s.split(" ");
			for(String t:token) {
				if(t.equals("+") || t.equals("-") || t.equals("*")){ 
					int num1=Integer.valueOf((String) stack.pop());
					int num2=Integer.valueOf((String) stack.pop());
					if(t.equals("+")) {
						stack.push(String.valueOf(num1+num2));
					}
					else if(t.equals("-")) {
						stack.push(String.valueOf(num2-num1));
					}
					else {
						stack.push(String.valueOf(num1*num2));
					}
					
				}
				else {
					stack.push(t);
				}
			}
			System.out.println(stack.pop());

		} {
			Stack<String> stack=new Stack<String>();
			String s=sc.nextLine();
			String[] token=s.split(" ");
			for(String t:token) {
				if(t.equals("+") || t.equals("-") || t.equals("*")){ 
					int num1=Integer.valueOf((String) stack.pop());
					int num2=Integer.valueOf((String) stack.pop());
					if(t.equals("+")) {
						stack.push(String.valueOf(num1+num2));
					}
					else if(t.equals("-")) {
						stack.push(String.valueOf(num2-num1));
					}
					else {
						stack.push(String.valueOf(num1*num2));
					}
					
				}
				else {
					stack.push(t);
				}
			}
			System.out.println(stack.pop());

		} Scanner sc = new Scanner(System.in) Scanner sc = new Scanner(System.in) new Scanner(System.in) Stack<String> stack=new Stack<String>(); stack new Stack<String>() String s=sc.nextLine(); s sc.nextLine() sc.nextLine sc String[] token=s.split(" "); token s.split(" ") s.split s " " for(String t:token) {
				if(t.equals("+") || t.equals("-") || t.equals("*")){ 
					int num1=Integer.valueOf((String) stack.pop());
					int num2=Integer.valueOf((String) stack.pop());
					if(t.equals("+")) {
						stack.push(String.valueOf(num1+num2));
					}
					else if(t.equals("-")) {
						stack.push(String.valueOf(num2-num1));
					}
					else {
						stack.push(String.valueOf(num1*num2));
					}
					
				}
				else {
					stack.push(t);
				}
			} String t token {
				if(t.equals("+") || t.equals("-") || t.equals("*")){ 
					int num1=Integer.valueOf((String) stack.pop());
					int num2=Integer.valueOf((String) stack.pop());
					if(t.equals("+")) {
						stack.push(String.valueOf(num1+num2));
					}
					else if(t.equals("-")) {
						stack.push(String.valueOf(num2-num1));
					}
					else {
						stack.push(String.valueOf(num1*num2));
					}
					
				}
				else {
					stack.push(t);
				}
			} {
				if(t.equals("+") || t.equals("-") || t.equals("*")){ 
					int num1=Integer.valueOf((String) stack.pop());
					int num2=Integer.valueOf((String) stack.pop());
					if(t.equals("+")) {
						stack.push(String.valueOf(num1+num2));
					}
					else if(t.equals("-")) {
						stack.push(String.valueOf(num2-num1));
					}
					else {
						stack.push(String.valueOf(num1*num2));
					}
					
				}
				else {
					stack.push(t);
				}
			} if(t.equals("+") || t.equals("-") || t.equals("*")){ 
					int num1=Integer.valueOf((String) stack.pop());
					int num2=Integer.valueOf((String) stack.pop());
					if(t.equals("+")) {
						stack.push(String.valueOf(num1+num2));
					}
					else if(t.equals("-")) {
						stack.push(String.valueOf(num2-num1));
					}
					else {
						stack.push(String.valueOf(num1*num2));
					}
					
				}
				else {
					stack.push(t);
				} t.equals("+") || t.equals("-") || t.equals("*") t.equals("+") || t.equals("-") || t.equals("*") t.equals("+") t.equals t "+" t.equals("-") t.equals t "-" t.equals("*") t.equals t "*" { 
					int num1=Integer.valueOf((String) stack.pop());
					int num2=Integer.valueOf((String) stack.pop());
					if(t.equals("+")) {
						stack.push(String.valueOf(num1+num2));
					}
					else if(t.equals("-")) {
						stack.push(String.valueOf(num2-num1));
					}
					else {
						stack.push(String.valueOf(num1*num2));
					}
					
				} int num1=Integer.valueOf((String) stack.pop()); num1 Integer.valueOf((String) stack.pop()) Integer.valueOf Integer (String) stack.pop() stack.pop stack int num2=Integer.valueOf((String) stack.pop()); num2 Integer.valueOf((String) stack.pop()) Integer.valueOf Integer (String) stack.pop() stack.pop stack if(t.equals("+")) {
						stack.push(String.valueOf(num1+num2));
					}
					else if(t.equals("-")) {
						stack.push(String.valueOf(num2-num1));
					}
					else {
						stack.push(String.valueOf(num1*num2));
					} t.equals("+") t.equals t "+" {
						stack.push(String.valueOf(num1+num2));
					} stack.push(String.valueOf(num1+num2)) stack.push stack String.valueOf(num1+num2) String.valueOf String num1+num2 num1 num2 if(t.equals("-")) {
						stack.push(String.valueOf(num2-num1));
					}
					else {
						stack.push(String.valueOf(num1*num2));
					} t.equals("-") t.equals t "-" {
						stack.push(String.valueOf(num2-num1));
					} stack.push(String.valueOf(num2-num1)) stack.push stack String.valueOf(num2-num1) String.valueOf String num2-num1 num2 num1 {
						stack.push(String.valueOf(num1*num2));
					} stack.push(String.valueOf(num1*num2)) stack.push stack String.valueOf(num1*num2) String.valueOf String num1*num2 num1 num2 {
					stack.push(t);
				} stack.push(t) stack.push stack t System.out.println(stack.pop()) System.out.println System.out System System.out stack.pop() stack.pop stack String[] args args public class Main {
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)){
			Stack<String> stack=new Stack<String>();
			String s=sc.nextLine();
			String[] token=s.split(" ");
			for(String t:token) {
				if(t.equals("+") || t.equals("-") || t.equals("*")){ 
					int num1=Integer.valueOf((String) stack.pop());
					int num2=Integer.valueOf((String) stack.pop());
					if(t.equals("+")) {
						stack.push(String.valueOf(num1+num2));
					}
					else if(t.equals("-")) {
						stack.push(String.valueOf(num2-num1));
					}
					else {
						stack.push(String.valueOf(num1*num2));
					}
					
				}
				else {
					stack.push(t);
				}
			}
			System.out.println(stack.pop());

		}
	}
} public class Main {
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)){
			Stack<String> stack=new Stack<String>();
			String s=sc.nextLine();
			String[] token=s.split(" ");
			for(String t:token) {
				if(t.equals("+") || t.equals("-") || t.equals("*")){ 
					int num1=Integer.valueOf((String) stack.pop());
					int num2=Integer.valueOf((String) stack.pop());
					if(t.equals("+")) {
						stack.push(String.valueOf(num1+num2));
					}
					else if(t.equals("-")) {
						stack.push(String.valueOf(num2-num1));
					}
					else {
						stack.push(String.valueOf(num1*num2));
					}
					
				}
				else {
					stack.push(t);
				}
			}
			System.out.println(stack.pop());

		}
	}
} Main
import java.util.Scanner;
import java.util.Stack;

public class Main {
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)){
			Stack<String> stack=new Stack<String>();
			String s=sc.nextLine();
			String[] token=s.split(" ");
			for(String t:token) {
				if(t.equals("+") || t.equals("-") || t.equals("*")){ 
					int num1=Integer.valueOf((String) stack.pop());
					int num2=Integer.valueOf((String) stack.pop());
					if(t.equals("+")) {
						stack.push(String.valueOf(num1+num2));
					}
					else if(t.equals("-")) {
						stack.push(String.valueOf(num2-num1));
					}
					else {
						stack.push(String.valueOf(num1*num2));
					}
					
				}
				else {
					stack.push(t);
				}
			}
			System.out.println(stack.pop());

		}
	}
}
