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

public class Main {

	public static void main(String[] args) {
	Scanner input = new Scanner(System.in);
	String[] equation;
	equation = input.nextLine().split(" ");
	Stack<Integer> numbers = new Stack<Integer>();
	input.close();
	int solution = 0;
	for(int i = 0; i < equation.length; i++) {
		String operator;
		
		if(equation[i].equals("*") || equation[i].equals("+") || equation[i].equals("-")) {
			operator = equation[i];
			if(operator.equals("*")) {
				solution = (numbers.pop() * numbers.pop());
				numbers.push(solution);
			}
			else if(operator.equals("+")) {
				solution = (numbers.pop() + numbers.pop());
				numbers.push(solution);
			}
			else if(operator.equals("-")) {
				int first = numbers.pop();
				int second = numbers.pop();
				solution = ( second - first );
				numbers.push(solution);
			}
			
			
		}
		else {
			numbers.push(Integer.parseInt(equation[i]));
		}
		
		
	}
	System.out.println(solution);

		
	}
	
	

} import java.util.Scanner; Scanner java.util import java.util.Stack; Stack java.util public class Main {

	public static void main(String[] args) {
	Scanner input = new Scanner(System.in);
	String[] equation;
	equation = input.nextLine().split(" ");
	Stack<Integer> numbers = new Stack<Integer>();
	input.close();
	int solution = 0;
	for(int i = 0; i < equation.length; i++) {
		String operator;
		
		if(equation[i].equals("*") || equation[i].equals("+") || equation[i].equals("-")) {
			operator = equation[i];
			if(operator.equals("*")) {
				solution = (numbers.pop() * numbers.pop());
				numbers.push(solution);
			}
			else if(operator.equals("+")) {
				solution = (numbers.pop() + numbers.pop());
				numbers.push(solution);
			}
			else if(operator.equals("-")) {
				int first = numbers.pop();
				int second = numbers.pop();
				solution = ( second - first );
				numbers.push(solution);
			}
			
			
		}
		else {
			numbers.push(Integer.parseInt(equation[i]));
		}
		
		
	}
	System.out.println(solution);

		
	}
	
	

} Main public static void main(String[] args) {
	Scanner input = new Scanner(System.in);
	String[] equation;
	equation = input.nextLine().split(" ");
	Stack<Integer> numbers = new Stack<Integer>();
	input.close();
	int solution = 0;
	for(int i = 0; i < equation.length; i++) {
		String operator;
		
		if(equation[i].equals("*") || equation[i].equals("+") || equation[i].equals("-")) {
			operator = equation[i];
			if(operator.equals("*")) {
				solution = (numbers.pop() * numbers.pop());
				numbers.push(solution);
			}
			else if(operator.equals("+")) {
				solution = (numbers.pop() + numbers.pop());
				numbers.push(solution);
			}
			else if(operator.equals("-")) {
				int first = numbers.pop();
				int second = numbers.pop();
				solution = ( second - first );
				numbers.push(solution);
			}
			
			
		}
		else {
			numbers.push(Integer.parseInt(equation[i]));
		}
		
		
	}
	System.out.println(solution);

		
	} main {
	Scanner input = new Scanner(System.in);
	String[] equation;
	equation = input.nextLine().split(" ");
	Stack<Integer> numbers = new Stack<Integer>();
	input.close();
	int solution = 0;
	for(int i = 0; i < equation.length; i++) {
		String operator;
		
		if(equation[i].equals("*") || equation[i].equals("+") || equation[i].equals("-")) {
			operator = equation[i];
			if(operator.equals("*")) {
				solution = (numbers.pop() * numbers.pop());
				numbers.push(solution);
			}
			else if(operator.equals("+")) {
				solution = (numbers.pop() + numbers.pop());
				numbers.push(solution);
			}
			else if(operator.equals("-")) {
				int first = numbers.pop();
				int second = numbers.pop();
				solution = ( second - first );
				numbers.push(solution);
			}
			
			
		}
		else {
			numbers.push(Integer.parseInt(equation[i]));
		}
		
		
	}
	System.out.println(solution);

		
	} Scanner input = new Scanner(System.in); input new Scanner(System.in) String[] equation; equation equation = input.nextLine().split(" ") equation input.nextLine().split(" ") input.nextLine().split input.nextLine() input.nextLine input " " Stack<Integer> numbers = new Stack<Integer>(); numbers new Stack<Integer>() input.close() input.close input int solution = 0; solution 0 for(int i = 0; i < equation.length; i++) {
		String operator;
		
		if(equation[i].equals("*") || equation[i].equals("+") || equation[i].equals("-")) {
			operator = equation[i];
			if(operator.equals("*")) {
				solution = (numbers.pop() * numbers.pop());
				numbers.push(solution);
			}
			else if(operator.equals("+")) {
				solution = (numbers.pop() + numbers.pop());
				numbers.push(solution);
			}
			else if(operator.equals("-")) {
				int first = numbers.pop();
				int second = numbers.pop();
				solution = ( second - first );
				numbers.push(solution);
			}
			
			
		}
		else {
			numbers.push(Integer.parseInt(equation[i]));
		}
		
		
	} int i = 0; int i = 0; i 0 i < equation.length i equation.length equation equation.length i++ i++ i {
		String operator;
		
		if(equation[i].equals("*") || equation[i].equals("+") || equation[i].equals("-")) {
			operator = equation[i];
			if(operator.equals("*")) {
				solution = (numbers.pop() * numbers.pop());
				numbers.push(solution);
			}
			else if(operator.equals("+")) {
				solution = (numbers.pop() + numbers.pop());
				numbers.push(solution);
			}
			else if(operator.equals("-")) {
				int first = numbers.pop();
				int second = numbers.pop();
				solution = ( second - first );
				numbers.push(solution);
			}
			
			
		}
		else {
			numbers.push(Integer.parseInt(equation[i]));
		}
		
		
	} {
		String operator;
		
		if(equation[i].equals("*") || equation[i].equals("+") || equation[i].equals("-")) {
			operator = equation[i];
			if(operator.equals("*")) {
				solution = (numbers.pop() * numbers.pop());
				numbers.push(solution);
			}
			else if(operator.equals("+")) {
				solution = (numbers.pop() + numbers.pop());
				numbers.push(solution);
			}
			else if(operator.equals("-")) {
				int first = numbers.pop();
				int second = numbers.pop();
				solution = ( second - first );
				numbers.push(solution);
			}
			
			
		}
		else {
			numbers.push(Integer.parseInt(equation[i]));
		}
		
		
	} String operator; operator if(equation[i].equals("*") || equation[i].equals("+") || equation[i].equals("-")) {
			operator = equation[i];
			if(operator.equals("*")) {
				solution = (numbers.pop() * numbers.pop());
				numbers.push(solution);
			}
			else if(operator.equals("+")) {
				solution = (numbers.pop() + numbers.pop());
				numbers.push(solution);
			}
			else if(operator.equals("-")) {
				int first = numbers.pop();
				int second = numbers.pop();
				solution = ( second - first );
				numbers.push(solution);
			}
			
			
		}
		else {
			numbers.push(Integer.parseInt(equation[i]));
		} equation[i].equals("*") || equation[i].equals("+") || equation[i].equals("-") equation[i].equals("*") || equation[i].equals("+") || equation[i].equals("-") equation[i].equals("*") equation[i].equals equation[i] equation i "*" equation[i].equals("+") equation[i].equals equation[i] equation i "+" equation[i].equals("-") equation[i].equals equation[i] equation i "-" {
			operator = equation[i];
			if(operator.equals("*")) {
				solution = (numbers.pop() * numbers.pop());
				numbers.push(solution);
			}
			else if(operator.equals("+")) {
				solution = (numbers.pop() + numbers.pop());
				numbers.push(solution);
			}
			else if(operator.equals("-")) {
				int first = numbers.pop();
				int second = numbers.pop();
				solution = ( second - first );
				numbers.push(solution);
			}
			
			
		} operator = equation[i] operator equation[i] equation i if(operator.equals("*")) {
				solution = (numbers.pop() * numbers.pop());
				numbers.push(solution);
			}
			else if(operator.equals("+")) {
				solution = (numbers.pop() + numbers.pop());
				numbers.push(solution);
			}
			else if(operator.equals("-")) {
				int first = numbers.pop();
				int second = numbers.pop();
				solution = ( second - first );
				numbers.push(solution);
			} operator.equals("*") operator.equals operator "*" {
				solution = (numbers.pop() * numbers.pop());
				numbers.push(solution);
			} solution = (numbers.pop() * numbers.pop()) solution (numbers.pop() * numbers.pop()) numbers.pop() numbers.pop numbers numbers.pop() numbers.pop numbers numbers.push(solution) numbers.push numbers solution if(operator.equals("+")) {
				solution = (numbers.pop() + numbers.pop());
				numbers.push(solution);
			}
			else if(operator.equals("-")) {
				int first = numbers.pop();
				int second = numbers.pop();
				solution = ( second - first );
				numbers.push(solution);
			} operator.equals("+") operator.equals operator "+" {
				solution = (numbers.pop() + numbers.pop());
				numbers.push(solution);
			} solution = (numbers.pop() + numbers.pop()) solution (numbers.pop() + numbers.pop()) numbers.pop() numbers.pop numbers numbers.pop() numbers.pop numbers numbers.push(solution) numbers.push numbers solution if(operator.equals("-")) {
				int first = numbers.pop();
				int second = numbers.pop();
				solution = ( second - first );
				numbers.push(solution);
			} operator.equals("-") operator.equals operator "-" {
				int first = numbers.pop();
				int second = numbers.pop();
				solution = ( second - first );
				numbers.push(solution);
			} int first = numbers.pop(); first numbers.pop() numbers.pop numbers int second = numbers.pop(); second numbers.pop() numbers.pop numbers solution = ( second - first ) solution ( second - first ) second first numbers.push(solution) numbers.push numbers solution {
			numbers.push(Integer.parseInt(equation[i]));
		} numbers.push(Integer.parseInt(equation[i])) numbers.push numbers Integer.parseInt(equation[i]) Integer.parseInt Integer equation[i] equation i System.out.println(solution) System.out.println System.out System System.out solution String[] args args public class Main {

	public static void main(String[] args) {
	Scanner input = new Scanner(System.in);
	String[] equation;
	equation = input.nextLine().split(" ");
	Stack<Integer> numbers = new Stack<Integer>();
	input.close();
	int solution = 0;
	for(int i = 0; i < equation.length; i++) {
		String operator;
		
		if(equation[i].equals("*") || equation[i].equals("+") || equation[i].equals("-")) {
			operator = equation[i];
			if(operator.equals("*")) {
				solution = (numbers.pop() * numbers.pop());
				numbers.push(solution);
			}
			else if(operator.equals("+")) {
				solution = (numbers.pop() + numbers.pop());
				numbers.push(solution);
			}
			else if(operator.equals("-")) {
				int first = numbers.pop();
				int second = numbers.pop();
				solution = ( second - first );
				numbers.push(solution);
			}
			
			
		}
		else {
			numbers.push(Integer.parseInt(equation[i]));
		}
		
		
	}
	System.out.println(solution);

		
	}
	
	

} public class Main {

	public static void main(String[] args) {
	Scanner input = new Scanner(System.in);
	String[] equation;
	equation = input.nextLine().split(" ");
	Stack<Integer> numbers = new Stack<Integer>();
	input.close();
	int solution = 0;
	for(int i = 0; i < equation.length; i++) {
		String operator;
		
		if(equation[i].equals("*") || equation[i].equals("+") || equation[i].equals("-")) {
			operator = equation[i];
			if(operator.equals("*")) {
				solution = (numbers.pop() * numbers.pop());
				numbers.push(solution);
			}
			else if(operator.equals("+")) {
				solution = (numbers.pop() + numbers.pop());
				numbers.push(solution);
			}
			else if(operator.equals("-")) {
				int first = numbers.pop();
				int second = numbers.pop();
				solution = ( second - first );
				numbers.push(solution);
			}
			
			
		}
		else {
			numbers.push(Integer.parseInt(equation[i]));
		}
		
		
	}
	System.out.println(solution);

		
	}
	
	

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

public class Main {

	public static void main(String[] args) {
	Scanner input = new Scanner(System.in);
	String[] equation;
	equation = input.nextLine().split(" ");
	Stack<Integer> numbers = new Stack<Integer>();
	input.close();
	int solution = 0;
	for(int i = 0; i < equation.length; i++) {
		String operator;
		
		if(equation[i].equals("*") || equation[i].equals("+") || equation[i].equals("-")) {
			operator = equation[i];
			if(operator.equals("*")) {
				solution = (numbers.pop() * numbers.pop());
				numbers.push(solution);
			}
			else if(operator.equals("+")) {
				solution = (numbers.pop() + numbers.pop());
				numbers.push(solution);
			}
			else if(operator.equals("-")) {
				int first = numbers.pop();
				int second = numbers.pop();
				solution = ( second - first );
				numbers.push(solution);
			}
			
			
		}
		else {
			numbers.push(Integer.parseInt(equation[i]));
		}
		
		
	}
	System.out.println(solution);

		
	}
	
	

}
