import java.util.*;

class Main{
	public static void main(String args[]){
		int i;
		int stacksize = 100;
		String temp;
		int calc;
		int a,b;
		Deque<Integer> stack = new ArrayDeque<Integer>();
		String separator = System.getProperty("line.separator");
		Scanner sc1 = new Scanner(System.in);
		String str = sc1.nextLine();
		Scanner sc2 = new Scanner(str);
		sc2.useDelimiter(" ");
		
		while(sc2.hasNext()){
			temp = sc2.next();
			if(temp.equals("+")){
				calc = stack.removeFirst() + stack.removeFirst();
				stack.addFirst(calc);
			}else if(temp.equals("-")){
				a = stack.removeFirst();
				b = stack.removeFirst();
				calc = b - a;
				stack.addFirst(calc);
			}else if(temp.equals("*")){
				calc = stack.removeFirst() * stack.removeFirst();
				stack.addFirst(calc);
			}else{
				stack.addFirst(Integer.parseInt(temp));
			}
		}
		System.out.println(stack.removeFirst());
	}
} import java.util.*; util.* java class Main{
	public static void main(String args[]){
		int i;
		int stacksize = 100;
		String temp;
		int calc;
		int a,b;
		Deque<Integer> stack = new ArrayDeque<Integer>();
		String separator = System.getProperty("line.separator");
		Scanner sc1 = new Scanner(System.in);
		String str = sc1.nextLine();
		Scanner sc2 = new Scanner(str);
		sc2.useDelimiter(" ");
		
		while(sc2.hasNext()){
			temp = sc2.next();
			if(temp.equals("+")){
				calc = stack.removeFirst() + stack.removeFirst();
				stack.addFirst(calc);
			}else if(temp.equals("-")){
				a = stack.removeFirst();
				b = stack.removeFirst();
				calc = b - a;
				stack.addFirst(calc);
			}else if(temp.equals("*")){
				calc = stack.removeFirst() * stack.removeFirst();
				stack.addFirst(calc);
			}else{
				stack.addFirst(Integer.parseInt(temp));
			}
		}
		System.out.println(stack.removeFirst());
	}
} Main public static void main(String args[]){
		int i;
		int stacksize = 100;
		String temp;
		int calc;
		int a,b;
		Deque<Integer> stack = new ArrayDeque<Integer>();
		String separator = System.getProperty("line.separator");
		Scanner sc1 = new Scanner(System.in);
		String str = sc1.nextLine();
		Scanner sc2 = new Scanner(str);
		sc2.useDelimiter(" ");
		
		while(sc2.hasNext()){
			temp = sc2.next();
			if(temp.equals("+")){
				calc = stack.removeFirst() + stack.removeFirst();
				stack.addFirst(calc);
			}else if(temp.equals("-")){
				a = stack.removeFirst();
				b = stack.removeFirst();
				calc = b - a;
				stack.addFirst(calc);
			}else if(temp.equals("*")){
				calc = stack.removeFirst() * stack.removeFirst();
				stack.addFirst(calc);
			}else{
				stack.addFirst(Integer.parseInt(temp));
			}
		}
		System.out.println(stack.removeFirst());
	} main {
		int i;
		int stacksize = 100;
		String temp;
		int calc;
		int a,b;
		Deque<Integer> stack = new ArrayDeque<Integer>();
		String separator = System.getProperty("line.separator");
		Scanner sc1 = new Scanner(System.in);
		String str = sc1.nextLine();
		Scanner sc2 = new Scanner(str);
		sc2.useDelimiter(" ");
		
		while(sc2.hasNext()){
			temp = sc2.next();
			if(temp.equals("+")){
				calc = stack.removeFirst() + stack.removeFirst();
				stack.addFirst(calc);
			}else if(temp.equals("-")){
				a = stack.removeFirst();
				b = stack.removeFirst();
				calc = b - a;
				stack.addFirst(calc);
			}else if(temp.equals("*")){
				calc = stack.removeFirst() * stack.removeFirst();
				stack.addFirst(calc);
			}else{
				stack.addFirst(Integer.parseInt(temp));
			}
		}
		System.out.println(stack.removeFirst());
	} int i; i int stacksize = 100; stacksize 100 String temp; temp int calc; calc int a a b; b Deque<Integer> stack = new ArrayDeque<Integer>(); stack new ArrayDeque<Integer>() String separator = System.getProperty("line.separator"); separator System.getProperty("line.separator") System.getProperty System "line.separator" Scanner sc1 = new Scanner(System.in); sc1 new Scanner(System.in) String str = sc1.nextLine(); str sc1.nextLine() sc1.nextLine sc1 Scanner sc2 = new Scanner(str); sc2 new Scanner(str) sc2.useDelimiter(" ") sc2.useDelimiter sc2 " " while(sc2.hasNext()){
			temp = sc2.next();
			if(temp.equals("+")){
				calc = stack.removeFirst() + stack.removeFirst();
				stack.addFirst(calc);
			}else if(temp.equals("-")){
				a = stack.removeFirst();
				b = stack.removeFirst();
				calc = b - a;
				stack.addFirst(calc);
			}else if(temp.equals("*")){
				calc = stack.removeFirst() * stack.removeFirst();
				stack.addFirst(calc);
			}else{
				stack.addFirst(Integer.parseInt(temp));
			}
		} sc2.hasNext() sc2.hasNext sc2 {
			temp = sc2.next();
			if(temp.equals("+")){
				calc = stack.removeFirst() + stack.removeFirst();
				stack.addFirst(calc);
			}else if(temp.equals("-")){
				a = stack.removeFirst();
				b = stack.removeFirst();
				calc = b - a;
				stack.addFirst(calc);
			}else if(temp.equals("*")){
				calc = stack.removeFirst() * stack.removeFirst();
				stack.addFirst(calc);
			}else{
				stack.addFirst(Integer.parseInt(temp));
			}
		} temp = sc2.next() temp sc2.next() sc2.next sc2 if(temp.equals("+")){
				calc = stack.removeFirst() + stack.removeFirst();
				stack.addFirst(calc);
			}else if(temp.equals("-")){
				a = stack.removeFirst();
				b = stack.removeFirst();
				calc = b - a;
				stack.addFirst(calc);
			}else if(temp.equals("*")){
				calc = stack.removeFirst() * stack.removeFirst();
				stack.addFirst(calc);
			}else{
				stack.addFirst(Integer.parseInt(temp));
			} temp.equals("+") temp.equals temp "+" {
				calc = stack.removeFirst() + stack.removeFirst();
				stack.addFirst(calc);
			} calc = stack.removeFirst() + stack.removeFirst() calc stack.removeFirst() + stack.removeFirst() stack.removeFirst() stack.removeFirst stack stack.removeFirst() stack.removeFirst stack stack.addFirst(calc) stack.addFirst stack calc if(temp.equals("-")){
				a = stack.removeFirst();
				b = stack.removeFirst();
				calc = b - a;
				stack.addFirst(calc);
			}else if(temp.equals("*")){
				calc = stack.removeFirst() * stack.removeFirst();
				stack.addFirst(calc);
			}else{
				stack.addFirst(Integer.parseInt(temp));
			} temp.equals("-") temp.equals temp "-" {
				a = stack.removeFirst();
				b = stack.removeFirst();
				calc = b - a;
				stack.addFirst(calc);
			} a = stack.removeFirst() a stack.removeFirst() stack.removeFirst stack b = stack.removeFirst() b stack.removeFirst() stack.removeFirst stack calc = b - a calc b - a b a stack.addFirst(calc) stack.addFirst stack calc if(temp.equals("*")){
				calc = stack.removeFirst() * stack.removeFirst();
				stack.addFirst(calc);
			}else{
				stack.addFirst(Integer.parseInt(temp));
			} temp.equals("*") temp.equals temp "*" {
				calc = stack.removeFirst() * stack.removeFirst();
				stack.addFirst(calc);
			} calc = stack.removeFirst() * stack.removeFirst() calc stack.removeFirst() * stack.removeFirst() stack.removeFirst() stack.removeFirst stack stack.removeFirst() stack.removeFirst stack stack.addFirst(calc) stack.addFirst stack calc {
				stack.addFirst(Integer.parseInt(temp));
			} stack.addFirst(Integer.parseInt(temp)) stack.addFirst stack Integer.parseInt(temp) Integer.parseInt Integer temp System.out.println(stack.removeFirst()) System.out.println System.out System System.out stack.removeFirst() stack.removeFirst stack String args[] args
import java.util.*;

class Main{
	public static void main(String args[]){
		int i;
		int stacksize = 100;
		String temp;
		int calc;
		int a,b;
		Deque<Integer> stack = new ArrayDeque<Integer>();
		String separator = System.getProperty("line.separator");
		Scanner sc1 = new Scanner(System.in);
		String str = sc1.nextLine();
		Scanner sc2 = new Scanner(str);
		sc2.useDelimiter(" ");
		
		while(sc2.hasNext()){
			temp = sc2.next();
			if(temp.equals("+")){
				calc = stack.removeFirst() + stack.removeFirst();
				stack.addFirst(calc);
			}else if(temp.equals("-")){
				a = stack.removeFirst();
				b = stack.removeFirst();
				calc = b - a;
				stack.addFirst(calc);
			}else if(temp.equals("*")){
				calc = stack.removeFirst() * stack.removeFirst();
				stack.addFirst(calc);
			}else{
				stack.addFirst(Integer.parseInt(temp));
			}
		}
		System.out.println(stack.removeFirst());
	}
}