import java.util.LinkedList;
import java.util.Scanner;

/**
 * @author kawakami
 *
 */
class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		StringBuilder sb = new StringBuilder();
		Scanner as = new Scanner(System.in);
		LinkedList<Integer> list = new LinkedList<Integer>();
		
		int a,b;
		int top = -1;
		String st = "";
		
		while(as.hasNext()){
			
			st = as.next();
			switch (st){
			case "+":
				a = list.remove(top);
				top--;
				b = list.remove(top);
				list.add(b+a);
				break;
				
			case "-":
				a = list.remove(top);
				top--;
				b = list.remove(top);
				list.add(b-a);
				break;
				
			case "*":
				a = list.remove(top);
				top--;
				b = list.remove(top);
				list.add(b*a);
				break;
				
			default :
				list.add(Integer.parseInt(st));
				top++;
			
			}
			
		}
		
		System.out.println(list.get(0).toString());

	}

} import java.util.LinkedList; LinkedList java.util import java.util.Scanner; Scanner java.util class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		StringBuilder sb = new StringBuilder();
		Scanner as = new Scanner(System.in);
		LinkedList<Integer> list = new LinkedList<Integer>();
		
		int a,b;
		int top = -1;
		String st = "";
		
		while(as.hasNext()){
			
			st = as.next();
			switch (st){
			case "+":
				a = list.remove(top);
				top--;
				b = list.remove(top);
				list.add(b+a);
				break;
				
			case "-":
				a = list.remove(top);
				top--;
				b = list.remove(top);
				list.add(b-a);
				break;
				
			case "*":
				a = list.remove(top);
				top--;
				b = list.remove(top);
				list.add(b*a);
				break;
				
			default :
				list.add(Integer.parseInt(st));
				top++;
			
			}
			
		}
		
		System.out.println(list.get(0).toString());

	}

} Main /**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		StringBuilder sb = new StringBuilder();
		Scanner as = new Scanner(System.in);
		LinkedList<Integer> list = new LinkedList<Integer>();
		
		int a,b;
		int top = -1;
		String st = "";
		
		while(as.hasNext()){
			
			st = as.next();
			switch (st){
			case "+":
				a = list.remove(top);
				top--;
				b = list.remove(top);
				list.add(b+a);
				break;
				
			case "-":
				a = list.remove(top);
				top--;
				b = list.remove(top);
				list.add(b-a);
				break;
				
			case "*":
				a = list.remove(top);
				top--;
				b = list.remove(top);
				list.add(b*a);
				break;
				
			default :
				list.add(Integer.parseInt(st));
				top++;
			
			}
			
		}
		
		System.out.println(list.get(0).toString());

	} main {
		// TODO Auto-generated method stub
		StringBuilder sb = new StringBuilder();
		Scanner as = new Scanner(System.in);
		LinkedList<Integer> list = new LinkedList<Integer>();
		
		int a,b;
		int top = -1;
		String st = "";
		
		while(as.hasNext()){
			
			st = as.next();
			switch (st){
			case "+":
				a = list.remove(top);
				top--;
				b = list.remove(top);
				list.add(b+a);
				break;
				
			case "-":
				a = list.remove(top);
				top--;
				b = list.remove(top);
				list.add(b-a);
				break;
				
			case "*":
				a = list.remove(top);
				top--;
				b = list.remove(top);
				list.add(b*a);
				break;
				
			default :
				list.add(Integer.parseInt(st));
				top++;
			
			}
			
		}
		
		System.out.println(list.get(0).toString());

	} StringBuilder sb = new StringBuilder(); sb new StringBuilder() Scanner as = new Scanner(System.in); as new Scanner(System.in) LinkedList<Integer> list = new LinkedList<Integer>(); list new LinkedList<Integer>() int a a b; b int top = -1; top -1 1 String st = ""; st "" while(as.hasNext()){
			
			st = as.next();
			switch (st){
			case "+":
				a = list.remove(top);
				top--;
				b = list.remove(top);
				list.add(b+a);
				break;
				
			case "-":
				a = list.remove(top);
				top--;
				b = list.remove(top);
				list.add(b-a);
				break;
				
			case "*":
				a = list.remove(top);
				top--;
				b = list.remove(top);
				list.add(b*a);
				break;
				
			default :
				list.add(Integer.parseInt(st));
				top++;
			
			}
			
		} as.hasNext() as.hasNext as {
			
			st = as.next();
			switch (st){
			case "+":
				a = list.remove(top);
				top--;
				b = list.remove(top);
				list.add(b+a);
				break;
				
			case "-":
				a = list.remove(top);
				top--;
				b = list.remove(top);
				list.add(b-a);
				break;
				
			case "*":
				a = list.remove(top);
				top--;
				b = list.remove(top);
				list.add(b*a);
				break;
				
			default :
				list.add(Integer.parseInt(st));
				top++;
			
			}
			
		} st = as.next() st as.next() as.next as switch (st){
			case "+":
				a = list.remove(top);
				top--;
				b = list.remove(top);
				list.add(b+a);
				break;
				
			case "-":
				a = list.remove(top);
				top--;
				b = list.remove(top);
				list.add(b-a);
				break;
				
			case "*":
				a = list.remove(top);
				top--;
				b = list.remove(top);
				list.add(b*a);
				break;
				
			default :
				list.add(Integer.parseInt(st));
				top++;
			
			} st case "+": "+" case "+": a = list.remove(top) a list.remove(top) list.remove list top top-- top b = list.remove(top) b list.remove(top) list.remove list top list.add(b+a) list.add list b+a b a break; case "-": "-" case "-": a = list.remove(top) a list.remove(top) list.remove list top top-- top b = list.remove(top) b list.remove(top) list.remove list top list.add(b-a) list.add list b-a b a break; case "*": "*" case "*": a = list.remove(top) a list.remove(top) list.remove list top top-- top b = list.remove(top) b list.remove(top) list.remove list top list.add(b*a) list.add list b*a b a break; default : default : list.add(Integer.parseInt(st)) list.add list Integer.parseInt(st) Integer.parseInt Integer st top++ top System.out.println(list.get(0).toString()) System.out.println System.out System System.out list.get(0).toString() list.get(0).toString list.get(0) list.get list 0 String[] args args
import java.util.LinkedList;
import java.util.Scanner;

/**
 * @author kawakami
 *
 */
class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		StringBuilder sb = new StringBuilder();
		Scanner as = new Scanner(System.in);
		LinkedList<Integer> list = new LinkedList<Integer>();
		
		int a,b;
		int top = -1;
		String st = "";
		
		while(as.hasNext()){
			
			st = as.next();
			switch (st){
			case "+":
				a = list.remove(top);
				top--;
				b = list.remove(top);
				list.add(b+a);
				break;
				
			case "-":
				a = list.remove(top);
				top--;
				b = list.remove(top);
				list.add(b-a);
				break;
				
			case "*":
				a = list.remove(top);
				top--;
				b = list.remove(top);
				list.add(b*a);
				break;
				
			default :
				list.add(Integer.parseInt(st));
				top++;
			
			}
			
		}
		
		System.out.println(list.get(0).toString());

	}

}