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

public class Main {
	private static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

	public static void main(String[] args) throws Exception {
		String[] array = br.readLine().split(" ");
		Deque<String> mainDeque = new ArrayDeque<>();
		for(String str: array){
			mainDeque.offerLast(str);
		}
		Deque<Integer> intDeque = new ArrayDeque<>();
		
		while(!mainDeque.isEmpty()){
			String str = mainDeque.pop();
			try{
				int iv = Integer.parseInt(str);
				intDeque.push(iv);
			}catch(NumberFormatException e){
				int v2 = intDeque.pop();
				int v1 = intDeque.pop();
				
				int result = 0;
				switch (str) {
				case "+":
					result = v1 + v2;
					break;
				case "-":
					result = v1 - v2;
					break;
				case "*":
					result = v1 * v2;
					break;
				}
				
				intDeque.push(result);
			}
		}
		
		System.out.println(intDeque.pop());
	}
}
 import java.io.BufferedReader; BufferedReader 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 {
	private static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

	public static void main(String[] args) throws Exception {
		String[] array = br.readLine().split(" ");
		Deque<String> mainDeque = new ArrayDeque<>();
		for(String str: array){
			mainDeque.offerLast(str);
		}
		Deque<Integer> intDeque = new ArrayDeque<>();
		
		while(!mainDeque.isEmpty()){
			String str = mainDeque.pop();
			try{
				int iv = Integer.parseInt(str);
				intDeque.push(iv);
			}catch(NumberFormatException e){
				int v2 = intDeque.pop();
				int v1 = intDeque.pop();
				
				int result = 0;
				switch (str) {
				case "+":
					result = v1 + v2;
					break;
				case "-":
					result = v1 - v2;
					break;
				case "*":
					result = v1 * v2;
					break;
				}
				
				intDeque.push(result);
			}
		}
		
		System.out.println(intDeque.pop());
	}
} Main private static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) public static void main(String[] args) throws Exception {
		String[] array = br.readLine().split(" ");
		Deque<String> mainDeque = new ArrayDeque<>();
		for(String str: array){
			mainDeque.offerLast(str);
		}
		Deque<Integer> intDeque = new ArrayDeque<>();
		
		while(!mainDeque.isEmpty()){
			String str = mainDeque.pop();
			try{
				int iv = Integer.parseInt(str);
				intDeque.push(iv);
			}catch(NumberFormatException e){
				int v2 = intDeque.pop();
				int v1 = intDeque.pop();
				
				int result = 0;
				switch (str) {
				case "+":
					result = v1 + v2;
					break;
				case "-":
					result = v1 - v2;
					break;
				case "*":
					result = v1 * v2;
					break;
				}
				
				intDeque.push(result);
			}
		}
		
		System.out.println(intDeque.pop());
	} main {
		String[] array = br.readLine().split(" ");
		Deque<String> mainDeque = new ArrayDeque<>();
		for(String str: array){
			mainDeque.offerLast(str);
		}
		Deque<Integer> intDeque = new ArrayDeque<>();
		
		while(!mainDeque.isEmpty()){
			String str = mainDeque.pop();
			try{
				int iv = Integer.parseInt(str);
				intDeque.push(iv);
			}catch(NumberFormatException e){
				int v2 = intDeque.pop();
				int v1 = intDeque.pop();
				
				int result = 0;
				switch (str) {
				case "+":
					result = v1 + v2;
					break;
				case "-":
					result = v1 - v2;
					break;
				case "*":
					result = v1 * v2;
					break;
				}
				
				intDeque.push(result);
			}
		}
		
		System.out.println(intDeque.pop());
	} String[] array = br.readLine().split(" "); array br.readLine().split(" ") br.readLine().split br.readLine() br.readLine br " " Deque<String> mainDeque = new ArrayDeque<>(); mainDeque new ArrayDeque<>() for(String str: array){
			mainDeque.offerLast(str);
		} String str array {
			mainDeque.offerLast(str);
		} {
			mainDeque.offerLast(str);
		} mainDeque.offerLast(str) mainDeque.offerLast mainDeque str Deque<Integer> intDeque = new ArrayDeque<>(); intDeque new ArrayDeque<>() while(!mainDeque.isEmpty()){
			String str = mainDeque.pop();
			try{
				int iv = Integer.parseInt(str);
				intDeque.push(iv);
			}catch(NumberFormatException e){
				int v2 = intDeque.pop();
				int v1 = intDeque.pop();
				
				int result = 0;
				switch (str) {
				case "+":
					result = v1 + v2;
					break;
				case "-":
					result = v1 - v2;
					break;
				case "*":
					result = v1 * v2;
					break;
				}
				
				intDeque.push(result);
			}
		} !mainDeque.isEmpty() mainDeque.isEmpty() mainDeque.isEmpty mainDeque {
			String str = mainDeque.pop();
			try{
				int iv = Integer.parseInt(str);
				intDeque.push(iv);
			}catch(NumberFormatException e){
				int v2 = intDeque.pop();
				int v1 = intDeque.pop();
				
				int result = 0;
				switch (str) {
				case "+":
					result = v1 + v2;
					break;
				case "-":
					result = v1 - v2;
					break;
				case "*":
					result = v1 * v2;
					break;
				}
				
				intDeque.push(result);
			}
		} String str = mainDeque.pop(); str mainDeque.pop() mainDeque.pop mainDeque try{
				int iv = Integer.parseInt(str);
				intDeque.push(iv);
			}catch(NumberFormatException e){
				int v2 = intDeque.pop();
				int v1 = intDeque.pop();
				
				int result = 0;
				switch (str) {
				case "+":
					result = v1 + v2;
					break;
				case "-":
					result = v1 - v2;
					break;
				case "*":
					result = v1 * v2;
					break;
				}
				
				intDeque.push(result);
			} catch(NumberFormatException e){
				int v2 = intDeque.pop();
				int v1 = intDeque.pop();
				
				int result = 0;
				switch (str) {
				case "+":
					result = v1 + v2;
					break;
				case "-":
					result = v1 - v2;
					break;
				case "*":
					result = v1 * v2;
					break;
				}
				
				intDeque.push(result);
			} NumberFormatException e {
				int v2 = intDeque.pop();
				int v1 = intDeque.pop();
				
				int result = 0;
				switch (str) {
				case "+":
					result = v1 + v2;
					break;
				case "-":
					result = v1 - v2;
					break;
				case "*":
					result = v1 * v2;
					break;
				}
				
				intDeque.push(result);
			} int v2 = intDeque.pop(); v2 intDeque.pop() intDeque.pop intDeque int v1 = intDeque.pop(); v1 intDeque.pop() intDeque.pop intDeque int result = 0; result 0 switch (str) {
				case "+":
					result = v1 + v2;
					break;
				case "-":
					result = v1 - v2;
					break;
				case "*":
					result = v1 * v2;
					break;
				} str case "+": "+" case "+": result = v1 + v2 result v1 + v2 v1 v2 break; case "-": "-" case "-": result = v1 - v2 result v1 - v2 v1 v2 break; case "*": "*" case "*": result = v1 * v2 result v1 * v2 v1 v2 break; intDeque.push(result) intDeque.push intDeque result {
				int iv = Integer.parseInt(str);
				intDeque.push(iv);
			} int iv = Integer.parseInt(str); iv Integer.parseInt(str) Integer.parseInt Integer str intDeque.push(iv) intDeque.push intDeque iv System.out.println(intDeque.pop()) System.out.println System.out System System.out intDeque.pop() intDeque.pop intDeque String[] args args public class Main {
	private static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

	public static void main(String[] args) throws Exception {
		String[] array = br.readLine().split(" ");
		Deque<String> mainDeque = new ArrayDeque<>();
		for(String str: array){
			mainDeque.offerLast(str);
		}
		Deque<Integer> intDeque = new ArrayDeque<>();
		
		while(!mainDeque.isEmpty()){
			String str = mainDeque.pop();
			try{
				int iv = Integer.parseInt(str);
				intDeque.push(iv);
			}catch(NumberFormatException e){
				int v2 = intDeque.pop();
				int v1 = intDeque.pop();
				
				int result = 0;
				switch (str) {
				case "+":
					result = v1 + v2;
					break;
				case "-":
					result = v1 - v2;
					break;
				case "*":
					result = v1 * v2;
					break;
				}
				
				intDeque.push(result);
			}
		}
		
		System.out.println(intDeque.pop());
	}
} public class Main {
	private static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

	public static void main(String[] args) throws Exception {
		String[] array = br.readLine().split(" ");
		Deque<String> mainDeque = new ArrayDeque<>();
		for(String str: array){
			mainDeque.offerLast(str);
		}
		Deque<Integer> intDeque = new ArrayDeque<>();
		
		while(!mainDeque.isEmpty()){
			String str = mainDeque.pop();
			try{
				int iv = Integer.parseInt(str);
				intDeque.push(iv);
			}catch(NumberFormatException e){
				int v2 = intDeque.pop();
				int v1 = intDeque.pop();
				
				int result = 0;
				switch (str) {
				case "+":
					result = v1 + v2;
					break;
				case "-":
					result = v1 - v2;
					break;
				case "*":
					result = v1 * v2;
					break;
				}
				
				intDeque.push(result);
			}
		}
		
		System.out.println(intDeque.pop());
	}
} Main
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.Deque;

public class Main {
	private static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

	public static void main(String[] args) throws Exception {
		String[] array = br.readLine().split(" ");
		Deque<String> mainDeque = new ArrayDeque<>();
		for(String str: array){
			mainDeque.offerLast(str);
		}
		Deque<Integer> intDeque = new ArrayDeque<>();
		
		while(!mainDeque.isEmpty()){
			String str = mainDeque.pop();
			try{
				int iv = Integer.parseInt(str);
				intDeque.push(iv);
			}catch(NumberFormatException e){
				int v2 = intDeque.pop();
				int v1 = intDeque.pop();
				
				int result = 0;
				switch (str) {
				case "+":
					result = v1 + v2;
					break;
				case "-":
					result = v1 - v2;
					break;
				case "*":
					result = v1 * v2;
					break;
				}
				
				intDeque.push(result);
			}
		}
		
		System.out.println(intDeque.pop());
	}
}

