import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.Deque;

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {
		// TODO ?????????????????????????????????????????????
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		String[] formula = br.readLine().split(" ");
		
		Deque<String> deq = new ArrayDeque<String>();
		
		for(int i = 0; i < formula.length; i++){
			int tmp1; 
			int tmp2;
			
			switch(formula[i]){
			case "+":
				tmp1 = Integer.parseInt(deq.removeFirst());
				tmp2 = Integer.parseInt(deq.removeFirst());
				
				deq.addFirst(Integer.toString(tmp2 + tmp1));
				break;
				
			case "*":
				tmp1 = Integer.parseInt(deq.removeFirst());
				tmp2 = Integer.parseInt(deq.removeFirst());
				
				deq.addFirst(Integer.toString(tmp2 * tmp1));
				break;
				
			case "-":
				tmp1 = Integer.parseInt(deq.removeFirst());
				tmp2 = Integer.parseInt(deq.removeFirst());
				
				deq.addFirst(Integer.toString(tmp2 - tmp1));
				break;
				
			default:
				deq.addFirst(formula[i]);
				break;
			}
		}
		
		System.out.println(deq.removeLast());
	}

} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io import java.util.ArrayDeque; ArrayDeque java.util import java.util.Deque; Deque java.util public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {
		// TODO ?????????????????????????????????????????????
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		String[] formula = br.readLine().split(" ");
		
		Deque<String> deq = new ArrayDeque<String>();
		
		for(int i = 0; i < formula.length; i++){
			int tmp1; 
			int tmp2;
			
			switch(formula[i]){
			case "+":
				tmp1 = Integer.parseInt(deq.removeFirst());
				tmp2 = Integer.parseInt(deq.removeFirst());
				
				deq.addFirst(Integer.toString(tmp2 + tmp1));
				break;
				
			case "*":
				tmp1 = Integer.parseInt(deq.removeFirst());
				tmp2 = Integer.parseInt(deq.removeFirst());
				
				deq.addFirst(Integer.toString(tmp2 * tmp1));
				break;
				
			case "-":
				tmp1 = Integer.parseInt(deq.removeFirst());
				tmp2 = Integer.parseInt(deq.removeFirst());
				
				deq.addFirst(Integer.toString(tmp2 - tmp1));
				break;
				
			default:
				deq.addFirst(formula[i]);
				break;
			}
		}
		
		System.out.println(deq.removeLast());
	}

} Main public static void main(String[] args) throws NumberFormatException, IOException {
		// TODO ?????????????????????????????????????????????
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		String[] formula = br.readLine().split(" ");
		
		Deque<String> deq = new ArrayDeque<String>();
		
		for(int i = 0; i < formula.length; i++){
			int tmp1; 
			int tmp2;
			
			switch(formula[i]){
			case "+":
				tmp1 = Integer.parseInt(deq.removeFirst());
				tmp2 = Integer.parseInt(deq.removeFirst());
				
				deq.addFirst(Integer.toString(tmp2 + tmp1));
				break;
				
			case "*":
				tmp1 = Integer.parseInt(deq.removeFirst());
				tmp2 = Integer.parseInt(deq.removeFirst());
				
				deq.addFirst(Integer.toString(tmp2 * tmp1));
				break;
				
			case "-":
				tmp1 = Integer.parseInt(deq.removeFirst());
				tmp2 = Integer.parseInt(deq.removeFirst());
				
				deq.addFirst(Integer.toString(tmp2 - tmp1));
				break;
				
			default:
				deq.addFirst(formula[i]);
				break;
			}
		}
		
		System.out.println(deq.removeLast());
	} main {
		// TODO ?????????????????????????????????????????????
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		String[] formula = br.readLine().split(" ");
		
		Deque<String> deq = new ArrayDeque<String>();
		
		for(int i = 0; i < formula.length; i++){
			int tmp1; 
			int tmp2;
			
			switch(formula[i]){
			case "+":
				tmp1 = Integer.parseInt(deq.removeFirst());
				tmp2 = Integer.parseInt(deq.removeFirst());
				
				deq.addFirst(Integer.toString(tmp2 + tmp1));
				break;
				
			case "*":
				tmp1 = Integer.parseInt(deq.removeFirst());
				tmp2 = Integer.parseInt(deq.removeFirst());
				
				deq.addFirst(Integer.toString(tmp2 * tmp1));
				break;
				
			case "-":
				tmp1 = Integer.parseInt(deq.removeFirst());
				tmp2 = Integer.parseInt(deq.removeFirst());
				
				deq.addFirst(Integer.toString(tmp2 - tmp1));
				break;
				
			default:
				deq.addFirst(formula[i]);
				break;
			}
		}
		
		System.out.println(deq.removeLast());
	} BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) String[] formula = br.readLine().split(" "); formula br.readLine().split(" ") br.readLine().split br.readLine() br.readLine br " " Deque<String> deq = new ArrayDeque<String>(); deq new ArrayDeque<String>() for(int i = 0; i < formula.length; i++){
			int tmp1; 
			int tmp2;
			
			switch(formula[i]){
			case "+":
				tmp1 = Integer.parseInt(deq.removeFirst());
				tmp2 = Integer.parseInt(deq.removeFirst());
				
				deq.addFirst(Integer.toString(tmp2 + tmp1));
				break;
				
			case "*":
				tmp1 = Integer.parseInt(deq.removeFirst());
				tmp2 = Integer.parseInt(deq.removeFirst());
				
				deq.addFirst(Integer.toString(tmp2 * tmp1));
				break;
				
			case "-":
				tmp1 = Integer.parseInt(deq.removeFirst());
				tmp2 = Integer.parseInt(deq.removeFirst());
				
				deq.addFirst(Integer.toString(tmp2 - tmp1));
				break;
				
			default:
				deq.addFirst(formula[i]);
				break;
			}
		} int i = 0; int i = 0; i 0 i < formula.length i formula.length formula formula.length i++ i++ i {
			int tmp1; 
			int tmp2;
			
			switch(formula[i]){
			case "+":
				tmp1 = Integer.parseInt(deq.removeFirst());
				tmp2 = Integer.parseInt(deq.removeFirst());
				
				deq.addFirst(Integer.toString(tmp2 + tmp1));
				break;
				
			case "*":
				tmp1 = Integer.parseInt(deq.removeFirst());
				tmp2 = Integer.parseInt(deq.removeFirst());
				
				deq.addFirst(Integer.toString(tmp2 * tmp1));
				break;
				
			case "-":
				tmp1 = Integer.parseInt(deq.removeFirst());
				tmp2 = Integer.parseInt(deq.removeFirst());
				
				deq.addFirst(Integer.toString(tmp2 - tmp1));
				break;
				
			default:
				deq.addFirst(formula[i]);
				break;
			}
		} {
			int tmp1; 
			int tmp2;
			
			switch(formula[i]){
			case "+":
				tmp1 = Integer.parseInt(deq.removeFirst());
				tmp2 = Integer.parseInt(deq.removeFirst());
				
				deq.addFirst(Integer.toString(tmp2 + tmp1));
				break;
				
			case "*":
				tmp1 = Integer.parseInt(deq.removeFirst());
				tmp2 = Integer.parseInt(deq.removeFirst());
				
				deq.addFirst(Integer.toString(tmp2 * tmp1));
				break;
				
			case "-":
				tmp1 = Integer.parseInt(deq.removeFirst());
				tmp2 = Integer.parseInt(deq.removeFirst());
				
				deq.addFirst(Integer.toString(tmp2 - tmp1));
				break;
				
			default:
				deq.addFirst(formula[i]);
				break;
			}
		} int tmp1; tmp1 int tmp2; tmp2 switch(formula[i]){
			case "+":
				tmp1 = Integer.parseInt(deq.removeFirst());
				tmp2 = Integer.parseInt(deq.removeFirst());
				
				deq.addFirst(Integer.toString(tmp2 + tmp1));
				break;
				
			case "*":
				tmp1 = Integer.parseInt(deq.removeFirst());
				tmp2 = Integer.parseInt(deq.removeFirst());
				
				deq.addFirst(Integer.toString(tmp2 * tmp1));
				break;
				
			case "-":
				tmp1 = Integer.parseInt(deq.removeFirst());
				tmp2 = Integer.parseInt(deq.removeFirst());
				
				deq.addFirst(Integer.toString(tmp2 - tmp1));
				break;
				
			default:
				deq.addFirst(formula[i]);
				break;
			} formula[i] formula i case "+": "+" case "+": tmp1 = Integer.parseInt(deq.removeFirst()) tmp1 Integer.parseInt(deq.removeFirst()) Integer.parseInt Integer deq.removeFirst() deq.removeFirst deq tmp2 = Integer.parseInt(deq.removeFirst()) tmp2 Integer.parseInt(deq.removeFirst()) Integer.parseInt Integer deq.removeFirst() deq.removeFirst deq deq.addFirst(Integer.toString(tmp2 + tmp1)) deq.addFirst deq Integer.toString(tmp2 + tmp1) Integer.toString Integer tmp2 + tmp1 tmp2 tmp1 break; case "*": "*" case "*": tmp1 = Integer.parseInt(deq.removeFirst()) tmp1 Integer.parseInt(deq.removeFirst()) Integer.parseInt Integer deq.removeFirst() deq.removeFirst deq tmp2 = Integer.parseInt(deq.removeFirst()) tmp2 Integer.parseInt(deq.removeFirst()) Integer.parseInt Integer deq.removeFirst() deq.removeFirst deq deq.addFirst(Integer.toString(tmp2 * tmp1)) deq.addFirst deq Integer.toString(tmp2 * tmp1) Integer.toString Integer tmp2 * tmp1 tmp2 tmp1 break; case "-": "-" case "-": tmp1 = Integer.parseInt(deq.removeFirst()) tmp1 Integer.parseInt(deq.removeFirst()) Integer.parseInt Integer deq.removeFirst() deq.removeFirst deq tmp2 = Integer.parseInt(deq.removeFirst()) tmp2 Integer.parseInt(deq.removeFirst()) Integer.parseInt Integer deq.removeFirst() deq.removeFirst deq deq.addFirst(Integer.toString(tmp2 - tmp1)) deq.addFirst deq Integer.toString(tmp2 - tmp1) Integer.toString Integer tmp2 - tmp1 tmp2 tmp1 break; default: default: deq.addFirst(formula[i]) deq.addFirst deq formula[i] formula i break; System.out.println(deq.removeLast()) System.out.println System.out System System.out deq.removeLast() deq.removeLast deq String[] args args public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {
		// TODO ?????????????????????????????????????????????
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		String[] formula = br.readLine().split(" ");
		
		Deque<String> deq = new ArrayDeque<String>();
		
		for(int i = 0; i < formula.length; i++){
			int tmp1; 
			int tmp2;
			
			switch(formula[i]){
			case "+":
				tmp1 = Integer.parseInt(deq.removeFirst());
				tmp2 = Integer.parseInt(deq.removeFirst());
				
				deq.addFirst(Integer.toString(tmp2 + tmp1));
				break;
				
			case "*":
				tmp1 = Integer.parseInt(deq.removeFirst());
				tmp2 = Integer.parseInt(deq.removeFirst());
				
				deq.addFirst(Integer.toString(tmp2 * tmp1));
				break;
				
			case "-":
				tmp1 = Integer.parseInt(deq.removeFirst());
				tmp2 = Integer.parseInt(deq.removeFirst());
				
				deq.addFirst(Integer.toString(tmp2 - tmp1));
				break;
				
			default:
				deq.addFirst(formula[i]);
				break;
			}
		}
		
		System.out.println(deq.removeLast());
	}

} public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {
		// TODO ?????????????????????????????????????????????
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		String[] formula = br.readLine().split(" ");
		
		Deque<String> deq = new ArrayDeque<String>();
		
		for(int i = 0; i < formula.length; i++){
			int tmp1; 
			int tmp2;
			
			switch(formula[i]){
			case "+":
				tmp1 = Integer.parseInt(deq.removeFirst());
				tmp2 = Integer.parseInt(deq.removeFirst());
				
				deq.addFirst(Integer.toString(tmp2 + tmp1));
				break;
				
			case "*":
				tmp1 = Integer.parseInt(deq.removeFirst());
				tmp2 = Integer.parseInt(deq.removeFirst());
				
				deq.addFirst(Integer.toString(tmp2 * tmp1));
				break;
				
			case "-":
				tmp1 = Integer.parseInt(deq.removeFirst());
				tmp2 = Integer.parseInt(deq.removeFirst());
				
				deq.addFirst(Integer.toString(tmp2 - tmp1));
				break;
				
			default:
				deq.addFirst(formula[i]);
				break;
			}
		}
		
		System.out.println(deq.removeLast());
	}

} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.Deque;

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {
		// TODO ?????????????????????????????????????????????
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		String[] formula = br.readLine().split(" ");
		
		Deque<String> deq = new ArrayDeque<String>();
		
		for(int i = 0; i < formula.length; i++){
			int tmp1; 
			int tmp2;
			
			switch(formula[i]){
			case "+":
				tmp1 = Integer.parseInt(deq.removeFirst());
				tmp2 = Integer.parseInt(deq.removeFirst());
				
				deq.addFirst(Integer.toString(tmp2 + tmp1));
				break;
				
			case "*":
				tmp1 = Integer.parseInt(deq.removeFirst());
				tmp2 = Integer.parseInt(deq.removeFirst());
				
				deq.addFirst(Integer.toString(tmp2 * tmp1));
				break;
				
			case "-":
				tmp1 = Integer.parseInt(deq.removeFirst());
				tmp2 = Integer.parseInt(deq.removeFirst());
				
				deq.addFirst(Integer.toString(tmp2 - tmp1));
				break;
				
			default:
				deq.addFirst(formula[i]);
				break;
			}
		}
		
		System.out.println(deq.removeLast());
	}

}