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

class Main {
	public static void main(String args[]) throws IOException{
		InputStreamReader isr = new InputStreamReader(System.in);
		BufferedReader br = new BufferedReader(isr);
		
		
		
		String str = br.readLine();
		String[] stA = (str.replaceAll("\\s+", " ")).split(" ", 0);
		
		//str.replaceAll("\\s+", " ") ??§??£?¶???????????????????????????????????????????????????????
		//?¬?????????????????????????????????????split(" ", 0)?????§?????????????????????????????¨??????????????????String???????????????
		
		Stack<String> stack = new Stack<String>();
		
		for(int i = 0; i < stA.length; i++) {
			if(stA[i].equals("+")) {
				//
				int a = new Integer(stack.pop().toString()).intValue();
				int b = new Integer(stack.pop().toString()).intValue();
				
				stack.push(String.valueOf(b+a));
				
			} else if(stA[i].equals("-")) {
				int a = new Integer(stack.pop().toString()).intValue();
				int b = new Integer(stack.pop().toString()).intValue();
				
				stack.push(String.valueOf(b-a));
				
			} else if(stA[i].equals("*")) {
				int a = new Integer(stack.pop().toString()).intValue();
				int b = new Integer(stack.pop().toString()).intValue();
				
				stack.push(String.valueOf(b*a));
				
			} else {
				stack.push(stA[i]);
			}
		}
		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 class Main {
	public static void main(String args[]) throws IOException{
		InputStreamReader isr = new InputStreamReader(System.in);
		BufferedReader br = new BufferedReader(isr);
		
		
		
		String str = br.readLine();
		String[] stA = (str.replaceAll("\\s+", " ")).split(" ", 0);
		
		//str.replaceAll("\\s+", " ") ??§??£?¶???????????????????????????????????????????????????????
		//?¬?????????????????????????????????????split(" ", 0)?????§?????????????????????????????¨??????????????????String???????????????
		
		Stack<String> stack = new Stack<String>();
		
		for(int i = 0; i < stA.length; i++) {
			if(stA[i].equals("+")) {
				//
				int a = new Integer(stack.pop().toString()).intValue();
				int b = new Integer(stack.pop().toString()).intValue();
				
				stack.push(String.valueOf(b+a));
				
			} else if(stA[i].equals("-")) {
				int a = new Integer(stack.pop().toString()).intValue();
				int b = new Integer(stack.pop().toString()).intValue();
				
				stack.push(String.valueOf(b-a));
				
			} else if(stA[i].equals("*")) {
				int a = new Integer(stack.pop().toString()).intValue();
				int b = new Integer(stack.pop().toString()).intValue();
				
				stack.push(String.valueOf(b*a));
				
			} else {
				stack.push(stA[i]);
			}
		}
		System.out.println(stack.pop());
	}
} Main public static void main(String args[]) throws IOException{
		InputStreamReader isr = new InputStreamReader(System.in);
		BufferedReader br = new BufferedReader(isr);
		
		
		
		String str = br.readLine();
		String[] stA = (str.replaceAll("\\s+", " ")).split(" ", 0);
		
		//str.replaceAll("\\s+", " ") ??§??£?¶???????????????????????????????????????????????????????
		//?¬?????????????????????????????????????split(" ", 0)?????§?????????????????????????????¨??????????????????String???????????????
		
		Stack<String> stack = new Stack<String>();
		
		for(int i = 0; i < stA.length; i++) {
			if(stA[i].equals("+")) {
				//
				int a = new Integer(stack.pop().toString()).intValue();
				int b = new Integer(stack.pop().toString()).intValue();
				
				stack.push(String.valueOf(b+a));
				
			} else if(stA[i].equals("-")) {
				int a = new Integer(stack.pop().toString()).intValue();
				int b = new Integer(stack.pop().toString()).intValue();
				
				stack.push(String.valueOf(b-a));
				
			} else if(stA[i].equals("*")) {
				int a = new Integer(stack.pop().toString()).intValue();
				int b = new Integer(stack.pop().toString()).intValue();
				
				stack.push(String.valueOf(b*a));
				
			} else {
				stack.push(stA[i]);
			}
		}
		System.out.println(stack.pop());
	} main {
		InputStreamReader isr = new InputStreamReader(System.in);
		BufferedReader br = new BufferedReader(isr);
		
		
		
		String str = br.readLine();
		String[] stA = (str.replaceAll("\\s+", " ")).split(" ", 0);
		
		//str.replaceAll("\\s+", " ") ??§??£?¶???????????????????????????????????????????????????????
		//?¬?????????????????????????????????????split(" ", 0)?????§?????????????????????????????¨??????????????????String???????????????
		
		Stack<String> stack = new Stack<String>();
		
		for(int i = 0; i < stA.length; i++) {
			if(stA[i].equals("+")) {
				//
				int a = new Integer(stack.pop().toString()).intValue();
				int b = new Integer(stack.pop().toString()).intValue();
				
				stack.push(String.valueOf(b+a));
				
			} else if(stA[i].equals("-")) {
				int a = new Integer(stack.pop().toString()).intValue();
				int b = new Integer(stack.pop().toString()).intValue();
				
				stack.push(String.valueOf(b-a));
				
			} else if(stA[i].equals("*")) {
				int a = new Integer(stack.pop().toString()).intValue();
				int b = new Integer(stack.pop().toString()).intValue();
				
				stack.push(String.valueOf(b*a));
				
			} else {
				stack.push(stA[i]);
			}
		}
		System.out.println(stack.pop());
	} InputStreamReader isr = new InputStreamReader(System.in); isr new InputStreamReader(System.in) BufferedReader br = new BufferedReader(isr); br new BufferedReader(isr) String str = br.readLine(); str br.readLine() br.readLine br String[] stA = (str.replaceAll("\\s+", " ")).split(" ", 0); stA (str.replaceAll("\\s+", " ")).split(" ", 0) (str.replaceAll("\\s+", " ")).split (str.replaceAll("\\s+", " ")) str.replaceAll str "\\s+" " " " " 0 Stack<String> stack = new Stack<String>(); stack new Stack<String>() for(int i = 0; i < stA.length; i++) {
			if(stA[i].equals("+")) {
				//
				int a = new Integer(stack.pop().toString()).intValue();
				int b = new Integer(stack.pop().toString()).intValue();
				
				stack.push(String.valueOf(b+a));
				
			} else if(stA[i].equals("-")) {
				int a = new Integer(stack.pop().toString()).intValue();
				int b = new Integer(stack.pop().toString()).intValue();
				
				stack.push(String.valueOf(b-a));
				
			} else if(stA[i].equals("*")) {
				int a = new Integer(stack.pop().toString()).intValue();
				int b = new Integer(stack.pop().toString()).intValue();
				
				stack.push(String.valueOf(b*a));
				
			} else {
				stack.push(stA[i]);
			}
		} int i = 0; int i = 0; i 0 i < stA.length i stA.length stA stA.length i++ i++ i {
			if(stA[i].equals("+")) {
				//
				int a = new Integer(stack.pop().toString()).intValue();
				int b = new Integer(stack.pop().toString()).intValue();
				
				stack.push(String.valueOf(b+a));
				
			} else if(stA[i].equals("-")) {
				int a = new Integer(stack.pop().toString()).intValue();
				int b = new Integer(stack.pop().toString()).intValue();
				
				stack.push(String.valueOf(b-a));
				
			} else if(stA[i].equals("*")) {
				int a = new Integer(stack.pop().toString()).intValue();
				int b = new Integer(stack.pop().toString()).intValue();
				
				stack.push(String.valueOf(b*a));
				
			} else {
				stack.push(stA[i]);
			}
		} {
			if(stA[i].equals("+")) {
				//
				int a = new Integer(stack.pop().toString()).intValue();
				int b = new Integer(stack.pop().toString()).intValue();
				
				stack.push(String.valueOf(b+a));
				
			} else if(stA[i].equals("-")) {
				int a = new Integer(stack.pop().toString()).intValue();
				int b = new Integer(stack.pop().toString()).intValue();
				
				stack.push(String.valueOf(b-a));
				
			} else if(stA[i].equals("*")) {
				int a = new Integer(stack.pop().toString()).intValue();
				int b = new Integer(stack.pop().toString()).intValue();
				
				stack.push(String.valueOf(b*a));
				
			} else {
				stack.push(stA[i]);
			}
		} if(stA[i].equals("+")) {
				//
				int a = new Integer(stack.pop().toString()).intValue();
				int b = new Integer(stack.pop().toString()).intValue();
				
				stack.push(String.valueOf(b+a));
				
			} else if(stA[i].equals("-")) {
				int a = new Integer(stack.pop().toString()).intValue();
				int b = new Integer(stack.pop().toString()).intValue();
				
				stack.push(String.valueOf(b-a));
				
			} else if(stA[i].equals("*")) {
				int a = new Integer(stack.pop().toString()).intValue();
				int b = new Integer(stack.pop().toString()).intValue();
				
				stack.push(String.valueOf(b*a));
				
			} else {
				stack.push(stA[i]);
			} stA[i].equals("+") stA[i].equals stA[i] stA i "+" {
				//
				int a = new Integer(stack.pop().toString()).intValue();
				int b = new Integer(stack.pop().toString()).intValue();
				
				stack.push(String.valueOf(b+a));
				
			} int a = new Integer(stack.pop().toString()).intValue(); a new Integer(stack.pop().toString()).intValue() new Integer(stack.pop().toString()).intValue new Integer(stack.pop().toString()) int b = new Integer(stack.pop().toString()).intValue(); b new Integer(stack.pop().toString()).intValue() new Integer(stack.pop().toString()).intValue new Integer(stack.pop().toString()) stack.push(String.valueOf(b+a)) stack.push stack String.valueOf(b+a) String.valueOf String b+a b a if(stA[i].equals("-")) {
				int a = new Integer(stack.pop().toString()).intValue();
				int b = new Integer(stack.pop().toString()).intValue();
				
				stack.push(String.valueOf(b-a));
				
			} else if(stA[i].equals("*")) {
				int a = new Integer(stack.pop().toString()).intValue();
				int b = new Integer(stack.pop().toString()).intValue();
				
				stack.push(String.valueOf(b*a));
				
			} else {
				stack.push(stA[i]);
			} stA[i].equals("-") stA[i].equals stA[i] stA i "-" {
				int a = new Integer(stack.pop().toString()).intValue();
				int b = new Integer(stack.pop().toString()).intValue();
				
				stack.push(String.valueOf(b-a));
				
			} int a = new Integer(stack.pop().toString()).intValue(); a new Integer(stack.pop().toString()).intValue() new Integer(stack.pop().toString()).intValue new Integer(stack.pop().toString()) int b = new Integer(stack.pop().toString()).intValue(); b new Integer(stack.pop().toString()).intValue() new Integer(stack.pop().toString()).intValue new Integer(stack.pop().toString()) stack.push(String.valueOf(b-a)) stack.push stack String.valueOf(b-a) String.valueOf String b-a b a if(stA[i].equals("*")) {
				int a = new Integer(stack.pop().toString()).intValue();
				int b = new Integer(stack.pop().toString()).intValue();
				
				stack.push(String.valueOf(b*a));
				
			} else {
				stack.push(stA[i]);
			} stA[i].equals("*") stA[i].equals stA[i] stA i "*" {
				int a = new Integer(stack.pop().toString()).intValue();
				int b = new Integer(stack.pop().toString()).intValue();
				
				stack.push(String.valueOf(b*a));
				
			} int a = new Integer(stack.pop().toString()).intValue(); a new Integer(stack.pop().toString()).intValue() new Integer(stack.pop().toString()).intValue new Integer(stack.pop().toString()) int b = new Integer(stack.pop().toString()).intValue(); b new Integer(stack.pop().toString()).intValue() new Integer(stack.pop().toString()).intValue new Integer(stack.pop().toString()) stack.push(String.valueOf(b*a)) stack.push stack String.valueOf(b*a) String.valueOf String b*a b a {
				stack.push(stA[i]);
			} stack.push(stA[i]) stack.push stack stA[i] stA i System.out.println(stack.pop()) System.out.println System.out System System.out stack.pop() stack.pop stack String args[] args
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Stack;

class Main {
	public static void main(String args[]) throws IOException{
		InputStreamReader isr = new InputStreamReader(System.in);
		BufferedReader br = new BufferedReader(isr);
		
		
		
		String str = br.readLine();
		String[] stA = (str.replaceAll("\\s+", " ")).split(" ", 0);
		
		//str.replaceAll("\\s+", " ") ??§??£?¶???????????????????????????????????????????????????????
		//?¬?????????????????????????????????????split(" ", 0)?????§?????????????????????????????¨??????????????????String???????????????
		
		Stack<String> stack = new Stack<String>();
		
		for(int i = 0; i < stA.length; i++) {
			if(stA[i].equals("+")) {
				//
				int a = new Integer(stack.pop().toString()).intValue();
				int b = new Integer(stack.pop().toString()).intValue();
				
				stack.push(String.valueOf(b+a));
				
			} else if(stA[i].equals("-")) {
				int a = new Integer(stack.pop().toString()).intValue();
				int b = new Integer(stack.pop().toString()).intValue();
				
				stack.push(String.valueOf(b-a));
				
			} else if(stA[i].equals("*")) {
				int a = new Integer(stack.pop().toString()).intValue();
				int b = new Integer(stack.pop().toString()).intValue();
				
				stack.push(String.valueOf(b*a));
				
			} else {
				stack.push(stA[i]);
			}
		}
		System.out.println(stack.pop());
	}
}