import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Stack;

public class Main {

	public static void main(String[] args) throws IOException {
		// TODO ?????????????????????????????????????????????
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String[] strArray = br.readLine().split(" ");
		Stack<Integer> stack = new Stack<Integer>();
		
		for(int i = 0; i < strArray.length ; i++){
			char input = strArray[i].charAt(0);
			if(Character.isDigit(input)){
				stack.push(Integer.parseInt(strArray[i]));
			}
			else {
				int tmpResult = 0;
				if(input == '+'){
					tmpResult = stack.pop() + stack.pop();
				}
				else if(input == '-'){
					tmpResult = -(stack.pop() - stack.pop());
				}
				else if(input == '*'){
					tmpResult = stack.pop() * stack.pop();
				}	
				//System.out.println(tmpResult);
				stack.push(tmpResult);
			}
		}
		
		System.out.println(stack.pop());
	}

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

	public static void main(String[] args) throws IOException {
		// TODO ?????????????????????????????????????????????
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String[] strArray = br.readLine().split(" ");
		Stack<Integer> stack = new Stack<Integer>();
		
		for(int i = 0; i < strArray.length ; i++){
			char input = strArray[i].charAt(0);
			if(Character.isDigit(input)){
				stack.push(Integer.parseInt(strArray[i]));
			}
			else {
				int tmpResult = 0;
				if(input == '+'){
					tmpResult = stack.pop() + stack.pop();
				}
				else if(input == '-'){
					tmpResult = -(stack.pop() - stack.pop());
				}
				else if(input == '*'){
					tmpResult = stack.pop() * stack.pop();
				}	
				//System.out.println(tmpResult);
				stack.push(tmpResult);
			}
		}
		
		System.out.println(stack.pop());
	}

} Main public static void main(String[] args) throws IOException {
		// TODO ?????????????????????????????????????????????
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String[] strArray = br.readLine().split(" ");
		Stack<Integer> stack = new Stack<Integer>();
		
		for(int i = 0; i < strArray.length ; i++){
			char input = strArray[i].charAt(0);
			if(Character.isDigit(input)){
				stack.push(Integer.parseInt(strArray[i]));
			}
			else {
				int tmpResult = 0;
				if(input == '+'){
					tmpResult = stack.pop() + stack.pop();
				}
				else if(input == '-'){
					tmpResult = -(stack.pop() - stack.pop());
				}
				else if(input == '*'){
					tmpResult = stack.pop() * stack.pop();
				}	
				//System.out.println(tmpResult);
				stack.push(tmpResult);
			}
		}
		
		System.out.println(stack.pop());
	} main {
		// TODO ?????????????????????????????????????????????
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String[] strArray = br.readLine().split(" ");
		Stack<Integer> stack = new Stack<Integer>();
		
		for(int i = 0; i < strArray.length ; i++){
			char input = strArray[i].charAt(0);
			if(Character.isDigit(input)){
				stack.push(Integer.parseInt(strArray[i]));
			}
			else {
				int tmpResult = 0;
				if(input == '+'){
					tmpResult = stack.pop() + stack.pop();
				}
				else if(input == '-'){
					tmpResult = -(stack.pop() - stack.pop());
				}
				else if(input == '*'){
					tmpResult = stack.pop() * stack.pop();
				}	
				//System.out.println(tmpResult);
				stack.push(tmpResult);
			}
		}
		
		System.out.println(stack.pop());
	} BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) String[] strArray = br.readLine().split(" "); strArray br.readLine().split(" ") br.readLine().split br.readLine() br.readLine br " " Stack<Integer> stack = new Stack<Integer>(); stack new Stack<Integer>() for(int i = 0; i < strArray.length ; i++){
			char input = strArray[i].charAt(0);
			if(Character.isDigit(input)){
				stack.push(Integer.parseInt(strArray[i]));
			}
			else {
				int tmpResult = 0;
				if(input == '+'){
					tmpResult = stack.pop() + stack.pop();
				}
				else if(input == '-'){
					tmpResult = -(stack.pop() - stack.pop());
				}
				else if(input == '*'){
					tmpResult = stack.pop() * stack.pop();
				}	
				//System.out.println(tmpResult);
				stack.push(tmpResult);
			}
		} int i = 0; int i = 0; i 0 i < strArray.length i strArray.length strArray strArray.length i++ i++ i {
			char input = strArray[i].charAt(0);
			if(Character.isDigit(input)){
				stack.push(Integer.parseInt(strArray[i]));
			}
			else {
				int tmpResult = 0;
				if(input == '+'){
					tmpResult = stack.pop() + stack.pop();
				}
				else if(input == '-'){
					tmpResult = -(stack.pop() - stack.pop());
				}
				else if(input == '*'){
					tmpResult = stack.pop() * stack.pop();
				}	
				//System.out.println(tmpResult);
				stack.push(tmpResult);
			}
		} {
			char input = strArray[i].charAt(0);
			if(Character.isDigit(input)){
				stack.push(Integer.parseInt(strArray[i]));
			}
			else {
				int tmpResult = 0;
				if(input == '+'){
					tmpResult = stack.pop() + stack.pop();
				}
				else if(input == '-'){
					tmpResult = -(stack.pop() - stack.pop());
				}
				else if(input == '*'){
					tmpResult = stack.pop() * stack.pop();
				}	
				//System.out.println(tmpResult);
				stack.push(tmpResult);
			}
		} char input = strArray[i].charAt(0); input strArray[i].charAt(0) strArray[i].charAt strArray[i] strArray i 0 if(Character.isDigit(input)){
				stack.push(Integer.parseInt(strArray[i]));
			}
			else {
				int tmpResult = 0;
				if(input == '+'){
					tmpResult = stack.pop() + stack.pop();
				}
				else if(input == '-'){
					tmpResult = -(stack.pop() - stack.pop());
				}
				else if(input == '*'){
					tmpResult = stack.pop() * stack.pop();
				}	
				//System.out.println(tmpResult);
				stack.push(tmpResult);
			} Character.isDigit(input) Character.isDigit Character input {
				stack.push(Integer.parseInt(strArray[i]));
			} stack.push(Integer.parseInt(strArray[i])) stack.push stack Integer.parseInt(strArray[i]) Integer.parseInt Integer strArray[i] strArray i {
				int tmpResult = 0;
				if(input == '+'){
					tmpResult = stack.pop() + stack.pop();
				}
				else if(input == '-'){
					tmpResult = -(stack.pop() - stack.pop());
				}
				else if(input == '*'){
					tmpResult = stack.pop() * stack.pop();
				}	
				//System.out.println(tmpResult);
				stack.push(tmpResult);
			} int tmpResult = 0; tmpResult 0 if(input == '+'){
					tmpResult = stack.pop() + stack.pop();
				}
				else if(input == '-'){
					tmpResult = -(stack.pop() - stack.pop());
				}
				else if(input == '*'){
					tmpResult = stack.pop() * stack.pop();
				} input == '+' input '+' {
					tmpResult = stack.pop() + stack.pop();
				} tmpResult = stack.pop() + stack.pop() tmpResult stack.pop() + stack.pop() stack.pop() stack.pop stack stack.pop() stack.pop stack if(input == '-'){
					tmpResult = -(stack.pop() - stack.pop());
				}
				else if(input == '*'){
					tmpResult = stack.pop() * stack.pop();
				} input == '-' input '-' {
					tmpResult = -(stack.pop() - stack.pop());
				} tmpResult = -(stack.pop() - stack.pop()) tmpResult -(stack.pop() - stack.pop()) (stack.pop() - stack.pop()) stack.pop() stack.pop stack stack.pop() stack.pop stack if(input == '*'){
					tmpResult = stack.pop() * stack.pop();
				} input == '*' input '*' {
					tmpResult = stack.pop() * stack.pop();
				} tmpResult = stack.pop() * stack.pop() tmpResult stack.pop() * stack.pop() stack.pop() stack.pop stack stack.pop() stack.pop stack stack.push(tmpResult) stack.push stack tmpResult System.out.println(stack.pop()) System.out.println System.out System System.out stack.pop() stack.pop stack String[] args args public class Main {

	public static void main(String[] args) throws IOException {
		// TODO ?????????????????????????????????????????????
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String[] strArray = br.readLine().split(" ");
		Stack<Integer> stack = new Stack<Integer>();
		
		for(int i = 0; i < strArray.length ; i++){
			char input = strArray[i].charAt(0);
			if(Character.isDigit(input)){
				stack.push(Integer.parseInt(strArray[i]));
			}
			else {
				int tmpResult = 0;
				if(input == '+'){
					tmpResult = stack.pop() + stack.pop();
				}
				else if(input == '-'){
					tmpResult = -(stack.pop() - stack.pop());
				}
				else if(input == '*'){
					tmpResult = stack.pop() * stack.pop();
				}	
				//System.out.println(tmpResult);
				stack.push(tmpResult);
			}
		}
		
		System.out.println(stack.pop());
	}

} public class Main {

	public static void main(String[] args) throws IOException {
		// TODO ?????????????????????????????????????????????
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String[] strArray = br.readLine().split(" ");
		Stack<Integer> stack = new Stack<Integer>();
		
		for(int i = 0; i < strArray.length ; i++){
			char input = strArray[i].charAt(0);
			if(Character.isDigit(input)){
				stack.push(Integer.parseInt(strArray[i]));
			}
			else {
				int tmpResult = 0;
				if(input == '+'){
					tmpResult = stack.pop() + stack.pop();
				}
				else if(input == '-'){
					tmpResult = -(stack.pop() - stack.pop());
				}
				else if(input == '*'){
					tmpResult = stack.pop() * stack.pop();
				}	
				//System.out.println(tmpResult);
				stack.push(tmpResult);
			}
		}
		
		System.out.println(stack.pop());
	}

} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Stack;

public class Main {

	public static void main(String[] args) throws IOException {
		// TODO ?????????????????????????????????????????????
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String[] strArray = br.readLine().split(" ");
		Stack<Integer> stack = new Stack<Integer>();
		
		for(int i = 0; i < strArray.length ; i++){
			char input = strArray[i].charAt(0);
			if(Character.isDigit(input)){
				stack.push(Integer.parseInt(strArray[i]));
			}
			else {
				int tmpResult = 0;
				if(input == '+'){
					tmpResult = stack.pop() + stack.pop();
				}
				else if(input == '-'){
					tmpResult = -(stack.pop() - stack.pop());
				}
				else if(input == '*'){
					tmpResult = stack.pop() * stack.pop();
				}	
				//System.out.println(tmpResult);
				stack.push(tmpResult);
			}
		}
		
		System.out.println(stack.pop());
	}

}