import java.util.*;

public class Main {
	public static void main(String[] args) {
		Stack<Long> stack = new Stack<Long>();
		Scanner scanner0 = new Scanner(System.in);
		Scanner scanner = new Scanner(scanner0.nextLine());
		scanner0.close();
		
		while (scanner.hasNext()) {
			if (scanner.hasNextLong()) {
				stack.push(scanner.nextLong());
			} else {
				long operand2 = stack.pop();
				long operand1 = stack.pop();
				String operator = scanner.next();
				
				if (operator.equals("+")) {
					stack.push(operand1 + operand2);
				} else if (operator.equals("-")) {
					stack.push(operand1 - operand2);
				} else {
					stack.push(operand1 * operand2);
				}
			}
		}
				
		scanner.close();
		
		System.out.println(stack.pop());
	}
} 
 import java.util.*; util.* java public class Main {
	public static void main(String[] args) {
		Stack<Long> stack = new Stack<Long>();
		Scanner scanner0 = new Scanner(System.in);
		Scanner scanner = new Scanner(scanner0.nextLine());
		scanner0.close();
		
		while (scanner.hasNext()) {
			if (scanner.hasNextLong()) {
				stack.push(scanner.nextLong());
			} else {
				long operand2 = stack.pop();
				long operand1 = stack.pop();
				String operator = scanner.next();
				
				if (operator.equals("+")) {
					stack.push(operand1 + operand2);
				} else if (operator.equals("-")) {
					stack.push(operand1 - operand2);
				} else {
					stack.push(operand1 * operand2);
				}
			}
		}
				
		scanner.close();
		
		System.out.println(stack.pop());
	}
} Main public static void main(String[] args) {
		Stack<Long> stack = new Stack<Long>();
		Scanner scanner0 = new Scanner(System.in);
		Scanner scanner = new Scanner(scanner0.nextLine());
		scanner0.close();
		
		while (scanner.hasNext()) {
			if (scanner.hasNextLong()) {
				stack.push(scanner.nextLong());
			} else {
				long operand2 = stack.pop();
				long operand1 = stack.pop();
				String operator = scanner.next();
				
				if (operator.equals("+")) {
					stack.push(operand1 + operand2);
				} else if (operator.equals("-")) {
					stack.push(operand1 - operand2);
				} else {
					stack.push(operand1 * operand2);
				}
			}
		}
				
		scanner.close();
		
		System.out.println(stack.pop());
	} main {
		Stack<Long> stack = new Stack<Long>();
		Scanner scanner0 = new Scanner(System.in);
		Scanner scanner = new Scanner(scanner0.nextLine());
		scanner0.close();
		
		while (scanner.hasNext()) {
			if (scanner.hasNextLong()) {
				stack.push(scanner.nextLong());
			} else {
				long operand2 = stack.pop();
				long operand1 = stack.pop();
				String operator = scanner.next();
				
				if (operator.equals("+")) {
					stack.push(operand1 + operand2);
				} else if (operator.equals("-")) {
					stack.push(operand1 - operand2);
				} else {
					stack.push(operand1 * operand2);
				}
			}
		}
				
		scanner.close();
		
		System.out.println(stack.pop());
	} Stack<Long> stack = new Stack<Long>(); stack new Stack<Long>() Scanner scanner0 = new Scanner(System.in); scanner0 new Scanner(System.in) Scanner scanner = new Scanner(scanner0.nextLine()); scanner new Scanner(scanner0.nextLine()) scanner0.close() scanner0.close scanner0 while (scanner.hasNext()) {
			if (scanner.hasNextLong()) {
				stack.push(scanner.nextLong());
			} else {
				long operand2 = stack.pop();
				long operand1 = stack.pop();
				String operator = scanner.next();
				
				if (operator.equals("+")) {
					stack.push(operand1 + operand2);
				} else if (operator.equals("-")) {
					stack.push(operand1 - operand2);
				} else {
					stack.push(operand1 * operand2);
				}
			}
		} scanner.hasNext() scanner.hasNext scanner {
			if (scanner.hasNextLong()) {
				stack.push(scanner.nextLong());
			} else {
				long operand2 = stack.pop();
				long operand1 = stack.pop();
				String operator = scanner.next();
				
				if (operator.equals("+")) {
					stack.push(operand1 + operand2);
				} else if (operator.equals("-")) {
					stack.push(operand1 - operand2);
				} else {
					stack.push(operand1 * operand2);
				}
			}
		} if (scanner.hasNextLong()) {
				stack.push(scanner.nextLong());
			} else {
				long operand2 = stack.pop();
				long operand1 = stack.pop();
				String operator = scanner.next();
				
				if (operator.equals("+")) {
					stack.push(operand1 + operand2);
				} else if (operator.equals("-")) {
					stack.push(operand1 - operand2);
				} else {
					stack.push(operand1 * operand2);
				}
			} scanner.hasNextLong() scanner.hasNextLong scanner {
				stack.push(scanner.nextLong());
			} stack.push(scanner.nextLong()) stack.push stack scanner.nextLong() scanner.nextLong scanner {
				long operand2 = stack.pop();
				long operand1 = stack.pop();
				String operator = scanner.next();
				
				if (operator.equals("+")) {
					stack.push(operand1 + operand2);
				} else if (operator.equals("-")) {
					stack.push(operand1 - operand2);
				} else {
					stack.push(operand1 * operand2);
				}
			} long operand2 = stack.pop(); operand2 stack.pop() stack.pop stack long operand1 = stack.pop(); operand1 stack.pop() stack.pop stack String operator = scanner.next(); operator scanner.next() scanner.next scanner if (operator.equals("+")) {
					stack.push(operand1 + operand2);
				} else if (operator.equals("-")) {
					stack.push(operand1 - operand2);
				} else {
					stack.push(operand1 * operand2);
				} operator.equals("+") operator.equals operator "+" {
					stack.push(operand1 + operand2);
				} stack.push(operand1 + operand2) stack.push stack operand1 + operand2 operand1 operand2 if (operator.equals("-")) {
					stack.push(operand1 - operand2);
				} else {
					stack.push(operand1 * operand2);
				} operator.equals("-") operator.equals operator "-" {
					stack.push(operand1 - operand2);
				} stack.push(operand1 - operand2) stack.push stack operand1 - operand2 operand1 operand2 {
					stack.push(operand1 * operand2);
				} stack.push(operand1 * operand2) stack.push stack operand1 * operand2 operand1 operand2 scanner.close() scanner.close scanner 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) {
		Stack<Long> stack = new Stack<Long>();
		Scanner scanner0 = new Scanner(System.in);
		Scanner scanner = new Scanner(scanner0.nextLine());
		scanner0.close();
		
		while (scanner.hasNext()) {
			if (scanner.hasNextLong()) {
				stack.push(scanner.nextLong());
			} else {
				long operand2 = stack.pop();
				long operand1 = stack.pop();
				String operator = scanner.next();
				
				if (operator.equals("+")) {
					stack.push(operand1 + operand2);
				} else if (operator.equals("-")) {
					stack.push(operand1 - operand2);
				} else {
					stack.push(operand1 * operand2);
				}
			}
		}
				
		scanner.close();
		
		System.out.println(stack.pop());
	}
} public class Main {
	public static void main(String[] args) {
		Stack<Long> stack = new Stack<Long>();
		Scanner scanner0 = new Scanner(System.in);
		Scanner scanner = new Scanner(scanner0.nextLine());
		scanner0.close();
		
		while (scanner.hasNext()) {
			if (scanner.hasNextLong()) {
				stack.push(scanner.nextLong());
			} else {
				long operand2 = stack.pop();
				long operand1 = stack.pop();
				String operator = scanner.next();
				
				if (operator.equals("+")) {
					stack.push(operand1 + operand2);
				} else if (operator.equals("-")) {
					stack.push(operand1 - operand2);
				} else {
					stack.push(operand1 * operand2);
				}
			}
		}
				
		scanner.close();
		
		System.out.println(stack.pop());
	}
} Main
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Stack<Long> stack = new Stack<Long>();
		Scanner scanner0 = new Scanner(System.in);
		Scanner scanner = new Scanner(scanner0.nextLine());
		scanner0.close();
		
		while (scanner.hasNext()) {
			if (scanner.hasNextLong()) {
				stack.push(scanner.nextLong());
			} else {
				long operand2 = stack.pop();
				long operand1 = stack.pop();
				String operator = scanner.next();
				
				if (operator.equals("+")) {
					stack.push(operand1 + operand2);
				} else if (operator.equals("-")) {
					stack.push(operand1 - operand2);
				} else {
					stack.push(operand1 * operand2);
				}
			}
		}
				
		scanner.close();
		
		System.out.println(stack.pop());
	}
} 

