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

//a trivial practice to evaluate reverse polish notation

public class Main {
	public static boolean is_operator(String token) {
		return token.equals("+") || token.equals("-") || token.equals("*");
	}
	
	
	public static int eval_simple_exp(int b, int a, String op) {
		if(op.equals("+")) return a + b;
		if(op.equals("-")) return a - b;
		if(op.equals("*")) return a * b;
		
		
		return 0;
	}
	
	
	//without any other validation about the expression's validity
	public static int eval_r_polish(String[] exp) {
		Stack<Integer> oprd_stk =new Stack<Integer>();
		int i = 0;
		
		
		while(i < exp.length) {
			String token = exp[i];
			if(is_operator(token)) {
				oprd_stk.push(eval_simple_exp(oprd_stk.pop(), oprd_stk.pop(), token));
			}else {
				oprd_stk.push(Integer.parseInt(token));
			}
			i++;
		}
		
		return oprd_stk.pop();
	}
	
	
	public static void main(String [] args) {
		Scanner cin = new Scanner(System.in);
		
		String str_exp = cin.nextLine();
		
		System.out.println(eval_r_polish(str_exp.split(" ")));
		
	}
} import java.util.Scanner; Scanner java.util import java.util.Stack; Stack java.util public class Main {
	public static boolean is_operator(String token) {
		return token.equals("+") || token.equals("-") || token.equals("*");
	}
	
	
	public static int eval_simple_exp(int b, int a, String op) {
		if(op.equals("+")) return a + b;
		if(op.equals("-")) return a - b;
		if(op.equals("*")) return a * b;
		
		
		return 0;
	}
	
	
	//without any other validation about the expression's validity
	public static int eval_r_polish(String[] exp) {
		Stack<Integer> oprd_stk =new Stack<Integer>();
		int i = 0;
		
		
		while(i < exp.length) {
			String token = exp[i];
			if(is_operator(token)) {
				oprd_stk.push(eval_simple_exp(oprd_stk.pop(), oprd_stk.pop(), token));
			}else {
				oprd_stk.push(Integer.parseInt(token));
			}
			i++;
		}
		
		return oprd_stk.pop();
	}
	
	
	public static void main(String [] args) {
		Scanner cin = new Scanner(System.in);
		
		String str_exp = cin.nextLine();
		
		System.out.println(eval_r_polish(str_exp.split(" ")));
		
	}
} Main public static boolean is_operator(String token) {
		return token.equals("+") || token.equals("-") || token.equals("*");
	} is_operator {
		return token.equals("+") || token.equals("-") || token.equals("*");
	} return token.equals("+") || token.equals("-") || token.equals("*"); token.equals("+") || token.equals("-") || token.equals("*") token.equals("+") || token.equals("-") || token.equals("*") token.equals("+") token.equals token "+" token.equals("-") token.equals token "-" token.equals("*") token.equals token "*" String token token public static int eval_simple_exp(int b, int a, String op) {
		if(op.equals("+")) return a + b;
		if(op.equals("-")) return a - b;
		if(op.equals("*")) return a * b;
		
		
		return 0;
	} eval_simple_exp {
		if(op.equals("+")) return a + b;
		if(op.equals("-")) return a - b;
		if(op.equals("*")) return a * b;
		
		
		return 0;
	} if(op.equals("+")) return a + b; op.equals("+") op.equals op "+" return a + b; a + b a b if(op.equals("-")) return a - b; op.equals("-") op.equals op "-" return a - b; a - b a b if(op.equals("*")) return a * b; op.equals("*") op.equals op "*" return a * b; a * b a b return 0; 0 int b b int a a String op op //without any other validation about the expression's validity
	public static int eval_r_polish(String[] exp) {
		Stack<Integer> oprd_stk =new Stack<Integer>();
		int i = 0;
		
		
		while(i < exp.length) {
			String token = exp[i];
			if(is_operator(token)) {
				oprd_stk.push(eval_simple_exp(oprd_stk.pop(), oprd_stk.pop(), token));
			}else {
				oprd_stk.push(Integer.parseInt(token));
			}
			i++;
		}
		
		return oprd_stk.pop();
	} eval_r_polish {
		Stack<Integer> oprd_stk =new Stack<Integer>();
		int i = 0;
		
		
		while(i < exp.length) {
			String token = exp[i];
			if(is_operator(token)) {
				oprd_stk.push(eval_simple_exp(oprd_stk.pop(), oprd_stk.pop(), token));
			}else {
				oprd_stk.push(Integer.parseInt(token));
			}
			i++;
		}
		
		return oprd_stk.pop();
	} Stack<Integer> oprd_stk =new Stack<Integer>(); oprd_stk new Stack<Integer>() int i = 0; i 0 while(i < exp.length) {
			String token = exp[i];
			if(is_operator(token)) {
				oprd_stk.push(eval_simple_exp(oprd_stk.pop(), oprd_stk.pop(), token));
			}else {
				oprd_stk.push(Integer.parseInt(token));
			}
			i++;
		} i < exp.length i exp.length exp exp.length {
			String token = exp[i];
			if(is_operator(token)) {
				oprd_stk.push(eval_simple_exp(oprd_stk.pop(), oprd_stk.pop(), token));
			}else {
				oprd_stk.push(Integer.parseInt(token));
			}
			i++;
		} String token = exp[i]; token exp[i] exp i if(is_operator(token)) {
				oprd_stk.push(eval_simple_exp(oprd_stk.pop(), oprd_stk.pop(), token));
			}else {
				oprd_stk.push(Integer.parseInt(token));
			} is_operator(token) is_operator token {
				oprd_stk.push(eval_simple_exp(oprd_stk.pop(), oprd_stk.pop(), token));
			} oprd_stk.push(eval_simple_exp(oprd_stk.pop(), oprd_stk.pop(), token)) oprd_stk.push oprd_stk eval_simple_exp(oprd_stk.pop(), oprd_stk.pop(), token) eval_simple_exp oprd_stk.pop() oprd_stk.pop oprd_stk oprd_stk.pop() oprd_stk.pop oprd_stk token {
				oprd_stk.push(Integer.parseInt(token));
			} oprd_stk.push(Integer.parseInt(token)) oprd_stk.push oprd_stk Integer.parseInt(token) Integer.parseInt Integer token i++ i return oprd_stk.pop(); oprd_stk.pop() oprd_stk.pop oprd_stk String[] exp exp public static void main(String [] args) {
		Scanner cin = new Scanner(System.in);
		
		String str_exp = cin.nextLine();
		
		System.out.println(eval_r_polish(str_exp.split(" ")));
		
	} main {
		Scanner cin = new Scanner(System.in);
		
		String str_exp = cin.nextLine();
		
		System.out.println(eval_r_polish(str_exp.split(" ")));
		
	} Scanner cin = new Scanner(System.in); cin new Scanner(System.in) String str_exp = cin.nextLine(); str_exp cin.nextLine() cin.nextLine cin System.out.println(eval_r_polish(str_exp.split(" "))) System.out.println System.out System System.out eval_r_polish(str_exp.split(" ")) eval_r_polish str_exp.split(" ") str_exp.split str_exp " " String [] args args public class Main {
	public static boolean is_operator(String token) {
		return token.equals("+") || token.equals("-") || token.equals("*");
	}
	
	
	public static int eval_simple_exp(int b, int a, String op) {
		if(op.equals("+")) return a + b;
		if(op.equals("-")) return a - b;
		if(op.equals("*")) return a * b;
		
		
		return 0;
	}
	
	
	//without any other validation about the expression's validity
	public static int eval_r_polish(String[] exp) {
		Stack<Integer> oprd_stk =new Stack<Integer>();
		int i = 0;
		
		
		while(i < exp.length) {
			String token = exp[i];
			if(is_operator(token)) {
				oprd_stk.push(eval_simple_exp(oprd_stk.pop(), oprd_stk.pop(), token));
			}else {
				oprd_stk.push(Integer.parseInt(token));
			}
			i++;
		}
		
		return oprd_stk.pop();
	}
	
	
	public static void main(String [] args) {
		Scanner cin = new Scanner(System.in);
		
		String str_exp = cin.nextLine();
		
		System.out.println(eval_r_polish(str_exp.split(" ")));
		
	}
} public class Main {
	public static boolean is_operator(String token) {
		return token.equals("+") || token.equals("-") || token.equals("*");
	}
	
	
	public static int eval_simple_exp(int b, int a, String op) {
		if(op.equals("+")) return a + b;
		if(op.equals("-")) return a - b;
		if(op.equals("*")) return a * b;
		
		
		return 0;
	}
	
	
	//without any other validation about the expression's validity
	public static int eval_r_polish(String[] exp) {
		Stack<Integer> oprd_stk =new Stack<Integer>();
		int i = 0;
		
		
		while(i < exp.length) {
			String token = exp[i];
			if(is_operator(token)) {
				oprd_stk.push(eval_simple_exp(oprd_stk.pop(), oprd_stk.pop(), token));
			}else {
				oprd_stk.push(Integer.parseInt(token));
			}
			i++;
		}
		
		return oprd_stk.pop();
	}
	
	
	public static void main(String [] args) {
		Scanner cin = new Scanner(System.in);
		
		String str_exp = cin.nextLine();
		
		System.out.println(eval_r_polish(str_exp.split(" ")));
		
	}
} Main

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

//a trivial practice to evaluate reverse polish notation

public class Main {
	public static boolean is_operator(String token) {
		return token.equals("+") || token.equals("-") || token.equals("*");
	}
	
	
	public static int eval_simple_exp(int b, int a, String op) {
		if(op.equals("+")) return a + b;
		if(op.equals("-")) return a - b;
		if(op.equals("*")) return a * b;
		
		
		return 0;
	}
	
	
	//without any other validation about the expression's validity
	public static int eval_r_polish(String[] exp) {
		Stack<Integer> oprd_stk =new Stack<Integer>();
		int i = 0;
		
		
		while(i < exp.length) {
			String token = exp[i];
			if(is_operator(token)) {
				oprd_stk.push(eval_simple_exp(oprd_stk.pop(), oprd_stk.pop(), token));
			}else {
				oprd_stk.push(Integer.parseInt(token));
			}
			i++;
		}
		
		return oprd_stk.pop();
	}
	
	
	public static void main(String [] args) {
		Scanner cin = new Scanner(System.in);
		
		String str_exp = cin.nextLine();
		
		System.out.println(eval_r_polish(str_exp.split(" ")));
		
	}
}