import java.io.*; 
import java.util.*; 
public class Main {
	
	
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		Stack<Integer> s = new Stack<>();
		while (in.hasNext()) {
			if (in.hasNextInt()) {
				s.push(in.nextInt());
			}
			else {
				String str = in.next();
			
				if(str.equals("+")) {
					int a = s.pop();
					int b = s.pop();
					s.push(a + b);
				}
				else if(str.equals("*")) {
					int a = s.pop();
					int b = s.pop();
					s.push(a * b);
				}
				else if(str.equals("-")) {
					int a = s.pop();
					int b = s.pop();
					s.push(b - a);
				}
			}
		}
		int result = s.pop();
		System.out.println(result);
	}
}
 import java.io.*; io.* java import java.util.*; util.* java public class Main {
	
	
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		Stack<Integer> s = new Stack<>();
		while (in.hasNext()) {
			if (in.hasNextInt()) {
				s.push(in.nextInt());
			}
			else {
				String str = in.next();
			
				if(str.equals("+")) {
					int a = s.pop();
					int b = s.pop();
					s.push(a + b);
				}
				else if(str.equals("*")) {
					int a = s.pop();
					int b = s.pop();
					s.push(a * b);
				}
				else if(str.equals("-")) {
					int a = s.pop();
					int b = s.pop();
					s.push(b - a);
				}
			}
		}
		int result = s.pop();
		System.out.println(result);
	}
} Main public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		Stack<Integer> s = new Stack<>();
		while (in.hasNext()) {
			if (in.hasNextInt()) {
				s.push(in.nextInt());
			}
			else {
				String str = in.next();
			
				if(str.equals("+")) {
					int a = s.pop();
					int b = s.pop();
					s.push(a + b);
				}
				else if(str.equals("*")) {
					int a = s.pop();
					int b = s.pop();
					s.push(a * b);
				}
				else if(str.equals("-")) {
					int a = s.pop();
					int b = s.pop();
					s.push(b - a);
				}
			}
		}
		int result = s.pop();
		System.out.println(result);
	} main {
		Scanner in = new Scanner(System.in);
		Stack<Integer> s = new Stack<>();
		while (in.hasNext()) {
			if (in.hasNextInt()) {
				s.push(in.nextInt());
			}
			else {
				String str = in.next();
			
				if(str.equals("+")) {
					int a = s.pop();
					int b = s.pop();
					s.push(a + b);
				}
				else if(str.equals("*")) {
					int a = s.pop();
					int b = s.pop();
					s.push(a * b);
				}
				else if(str.equals("-")) {
					int a = s.pop();
					int b = s.pop();
					s.push(b - a);
				}
			}
		}
		int result = s.pop();
		System.out.println(result);
	} Scanner in = new Scanner(System.in); in new Scanner(System.in) Stack<Integer> s = new Stack<>(); s new Stack<>() while (in.hasNext()) {
			if (in.hasNextInt()) {
				s.push(in.nextInt());
			}
			else {
				String str = in.next();
			
				if(str.equals("+")) {
					int a = s.pop();
					int b = s.pop();
					s.push(a + b);
				}
				else if(str.equals("*")) {
					int a = s.pop();
					int b = s.pop();
					s.push(a * b);
				}
				else if(str.equals("-")) {
					int a = s.pop();
					int b = s.pop();
					s.push(b - a);
				}
			}
		} in.hasNext() in.hasNext in {
			if (in.hasNextInt()) {
				s.push(in.nextInt());
			}
			else {
				String str = in.next();
			
				if(str.equals("+")) {
					int a = s.pop();
					int b = s.pop();
					s.push(a + b);
				}
				else if(str.equals("*")) {
					int a = s.pop();
					int b = s.pop();
					s.push(a * b);
				}
				else if(str.equals("-")) {
					int a = s.pop();
					int b = s.pop();
					s.push(b - a);
				}
			}
		} if (in.hasNextInt()) {
				s.push(in.nextInt());
			}
			else {
				String str = in.next();
			
				if(str.equals("+")) {
					int a = s.pop();
					int b = s.pop();
					s.push(a + b);
				}
				else if(str.equals("*")) {
					int a = s.pop();
					int b = s.pop();
					s.push(a * b);
				}
				else if(str.equals("-")) {
					int a = s.pop();
					int b = s.pop();
					s.push(b - a);
				}
			} in.hasNextInt() in.hasNextInt in {
				s.push(in.nextInt());
			} s.push(in.nextInt()) s.push s in.nextInt() in.nextInt in {
				String str = in.next();
			
				if(str.equals("+")) {
					int a = s.pop();
					int b = s.pop();
					s.push(a + b);
				}
				else if(str.equals("*")) {
					int a = s.pop();
					int b = s.pop();
					s.push(a * b);
				}
				else if(str.equals("-")) {
					int a = s.pop();
					int b = s.pop();
					s.push(b - a);
				}
			} String str = in.next(); str in.next() in.next in if(str.equals("+")) {
					int a = s.pop();
					int b = s.pop();
					s.push(a + b);
				}
				else if(str.equals("*")) {
					int a = s.pop();
					int b = s.pop();
					s.push(a * b);
				}
				else if(str.equals("-")) {
					int a = s.pop();
					int b = s.pop();
					s.push(b - a);
				} str.equals("+") str.equals str "+" {
					int a = s.pop();
					int b = s.pop();
					s.push(a + b);
				} int a = s.pop(); a s.pop() s.pop s int b = s.pop(); b s.pop() s.pop s s.push(a + b) s.push s a + b a b if(str.equals("*")) {
					int a = s.pop();
					int b = s.pop();
					s.push(a * b);
				}
				else if(str.equals("-")) {
					int a = s.pop();
					int b = s.pop();
					s.push(b - a);
				} str.equals("*") str.equals str "*" {
					int a = s.pop();
					int b = s.pop();
					s.push(a * b);
				} int a = s.pop(); a s.pop() s.pop s int b = s.pop(); b s.pop() s.pop s s.push(a * b) s.push s a * b a b if(str.equals("-")) {
					int a = s.pop();
					int b = s.pop();
					s.push(b - a);
				} str.equals("-") str.equals str "-" {
					int a = s.pop();
					int b = s.pop();
					s.push(b - a);
				} int a = s.pop(); a s.pop() s.pop s int b = s.pop(); b s.pop() s.pop s s.push(b - a) s.push s b - a b a int result = s.pop(); result s.pop() s.pop s System.out.println(result) System.out.println System.out System System.out result String[] args args public class Main {
	
	
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		Stack<Integer> s = new Stack<>();
		while (in.hasNext()) {
			if (in.hasNextInt()) {
				s.push(in.nextInt());
			}
			else {
				String str = in.next();
			
				if(str.equals("+")) {
					int a = s.pop();
					int b = s.pop();
					s.push(a + b);
				}
				else if(str.equals("*")) {
					int a = s.pop();
					int b = s.pop();
					s.push(a * b);
				}
				else if(str.equals("-")) {
					int a = s.pop();
					int b = s.pop();
					s.push(b - a);
				}
			}
		}
		int result = s.pop();
		System.out.println(result);
	}
} public class Main {
	
	
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		Stack<Integer> s = new Stack<>();
		while (in.hasNext()) {
			if (in.hasNextInt()) {
				s.push(in.nextInt());
			}
			else {
				String str = in.next();
			
				if(str.equals("+")) {
					int a = s.pop();
					int b = s.pop();
					s.push(a + b);
				}
				else if(str.equals("*")) {
					int a = s.pop();
					int b = s.pop();
					s.push(a * b);
				}
				else if(str.equals("-")) {
					int a = s.pop();
					int b = s.pop();
					s.push(b - a);
				}
			}
		}
		int result = s.pop();
		System.out.println(result);
	}
} Main
import java.io.*; 
import java.util.*; 
public class Main {
	
	
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		Stack<Integer> s = new Stack<>();
		while (in.hasNext()) {
			if (in.hasNextInt()) {
				s.push(in.nextInt());
			}
			else {
				String str = in.next();
			
				if(str.equals("+")) {
					int a = s.pop();
					int b = s.pop();
					s.push(a + b);
				}
				else if(str.equals("*")) {
					int a = s.pop();
					int b = s.pop();
					s.push(a * b);
				}
				else if(str.equals("-")) {
					int a = s.pop();
					int b = s.pop();
					s.push(b - a);
				}
			}
		}
		int result = s.pop();
		System.out.println(result);
	}
}

