

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	
	public static int top = 0;
	public static List<Integer> stack = new ArrayList<Integer>();

	public static void push(int x) {
		stack.add(x);
		top ++;
	}
	
	public static int pop() {
		top --;
		return stack.remove(top);
	}
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String[] inputs = sc.nextLine().split(" ");
		for (String in : inputs) {
			if (in.matches("[0-9]+")) {
				push(Integer.parseInt(in));
			} else {
				int b = pop();
				int a = pop();
				if ("+".equals(in)) 
					push(a+b);
				else if ("-".equals(in)) 
					push(a-b);
				else if ("*".equals(in)) 
					push(a*b);
			}
		}
		sc.close();
		
		System.out.println(pop());
	}

}
 import java.util.ArrayList; ArrayList java.util import java.util.List; List java.util import java.util.Scanner; Scanner java.util public class Main {
	
	public static int top = 0;
	public static List<Integer> stack = new ArrayList<Integer>();

	public static void push(int x) {
		stack.add(x);
		top ++;
	}
	
	public static int pop() {
		top --;
		return stack.remove(top);
	}
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String[] inputs = sc.nextLine().split(" ");
		for (String in : inputs) {
			if (in.matches("[0-9]+")) {
				push(Integer.parseInt(in));
			} else {
				int b = pop();
				int a = pop();
				if ("+".equals(in)) 
					push(a+b);
				else if ("-".equals(in)) 
					push(a-b);
				else if ("*".equals(in)) 
					push(a*b);
			}
		}
		sc.close();
		
		System.out.println(pop());
	}

} Main public static int top = 0; top 0 public static List<Integer> stack = new ArrayList<Integer>(); stack new ArrayList<Integer>() public static void push(int x) {
		stack.add(x);
		top ++;
	} push {
		stack.add(x);
		top ++;
	} stack.add(x) stack.add stack x top ++ top int x x public static int pop() {
		top --;
		return stack.remove(top);
	} pop {
		top --;
		return stack.remove(top);
	} top -- top return stack.remove(top); stack.remove(top) stack.remove stack top public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String[] inputs = sc.nextLine().split(" ");
		for (String in : inputs) {
			if (in.matches("[0-9]+")) {
				push(Integer.parseInt(in));
			} else {
				int b = pop();
				int a = pop();
				if ("+".equals(in)) 
					push(a+b);
				else if ("-".equals(in)) 
					push(a-b);
				else if ("*".equals(in)) 
					push(a*b);
			}
		}
		sc.close();
		
		System.out.println(pop());
	} main {
		Scanner sc = new Scanner(System.in);
		String[] inputs = sc.nextLine().split(" ");
		for (String in : inputs) {
			if (in.matches("[0-9]+")) {
				push(Integer.parseInt(in));
			} else {
				int b = pop();
				int a = pop();
				if ("+".equals(in)) 
					push(a+b);
				else if ("-".equals(in)) 
					push(a-b);
				else if ("*".equals(in)) 
					push(a*b);
			}
		}
		sc.close();
		
		System.out.println(pop());
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String[] inputs = sc.nextLine().split(" "); inputs sc.nextLine().split(" ") sc.nextLine().split sc.nextLine() sc.nextLine sc " " for (String in : inputs) {
			if (in.matches("[0-9]+")) {
				push(Integer.parseInt(in));
			} else {
				int b = pop();
				int a = pop();
				if ("+".equals(in)) 
					push(a+b);
				else if ("-".equals(in)) 
					push(a-b);
				else if ("*".equals(in)) 
					push(a*b);
			}
		} String in inputs {
			if (in.matches("[0-9]+")) {
				push(Integer.parseInt(in));
			} else {
				int b = pop();
				int a = pop();
				if ("+".equals(in)) 
					push(a+b);
				else if ("-".equals(in)) 
					push(a-b);
				else if ("*".equals(in)) 
					push(a*b);
			}
		} {
			if (in.matches("[0-9]+")) {
				push(Integer.parseInt(in));
			} else {
				int b = pop();
				int a = pop();
				if ("+".equals(in)) 
					push(a+b);
				else if ("-".equals(in)) 
					push(a-b);
				else if ("*".equals(in)) 
					push(a*b);
			}
		} if (in.matches("[0-9]+")) {
				push(Integer.parseInt(in));
			} else {
				int b = pop();
				int a = pop();
				if ("+".equals(in)) 
					push(a+b);
				else if ("-".equals(in)) 
					push(a-b);
				else if ("*".equals(in)) 
					push(a*b);
			} in.matches("[0-9]+") in.matches in "[0-9]+" {
				push(Integer.parseInt(in));
			} push(Integer.parseInt(in)) push Integer.parseInt(in) Integer.parseInt Integer in {
				int b = pop();
				int a = pop();
				if ("+".equals(in)) 
					push(a+b);
				else if ("-".equals(in)) 
					push(a-b);
				else if ("*".equals(in)) 
					push(a*b);
			} int b = pop(); b pop() pop int a = pop(); a pop() pop if ("+".equals(in)) 
					push(a+b);
				else if ("-".equals(in)) 
					push(a-b);
				else if ("*".equals(in)) 
					push(a*b); "+".equals(in) "+".equals "+" in push(a+b) push a+b a b if ("-".equals(in)) 
					push(a-b);
				else if ("*".equals(in)) 
					push(a*b); "-".equals(in) "-".equals "-" in push(a-b) push a-b a b if ("*".equals(in)) 
					push(a*b); "*".equals(in) "*".equals "*" in push(a*b) push a*b a b sc.close() sc.close sc System.out.println(pop()) System.out.println System.out System System.out pop() pop String[] args args public class Main {
	
	public static int top = 0;
	public static List<Integer> stack = new ArrayList<Integer>();

	public static void push(int x) {
		stack.add(x);
		top ++;
	}
	
	public static int pop() {
		top --;
		return stack.remove(top);
	}
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String[] inputs = sc.nextLine().split(" ");
		for (String in : inputs) {
			if (in.matches("[0-9]+")) {
				push(Integer.parseInt(in));
			} else {
				int b = pop();
				int a = pop();
				if ("+".equals(in)) 
					push(a+b);
				else if ("-".equals(in)) 
					push(a-b);
				else if ("*".equals(in)) 
					push(a*b);
			}
		}
		sc.close();
		
		System.out.println(pop());
	}

} public class Main {
	
	public static int top = 0;
	public static List<Integer> stack = new ArrayList<Integer>();

	public static void push(int x) {
		stack.add(x);
		top ++;
	}
	
	public static int pop() {
		top --;
		return stack.remove(top);
	}
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String[] inputs = sc.nextLine().split(" ");
		for (String in : inputs) {
			if (in.matches("[0-9]+")) {
				push(Integer.parseInt(in));
			} else {
				int b = pop();
				int a = pop();
				if ("+".equals(in)) 
					push(a+b);
				else if ("-".equals(in)) 
					push(a-b);
				else if ("*".equals(in)) 
					push(a*b);
			}
		}
		sc.close();
		
		System.out.println(pop());
	}

} Main


import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	
	public static int top = 0;
	public static List<Integer> stack = new ArrayList<Integer>();

	public static void push(int x) {
		stack.add(x);
		top ++;
	}
	
	public static int pop() {
		top --;
		return stack.remove(top);
	}
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String[] inputs = sc.nextLine().split(" ");
		for (String in : inputs) {
			if (in.matches("[0-9]+")) {
				push(Integer.parseInt(in));
			} else {
				int b = pop();
				int a = pop();
				if ("+".equals(in)) 
					push(a+b);
				else if ("-".equals(in)) 
					push(a-b);
				else if ("*".equals(in)) 
					push(a*b);
			}
		}
		sc.close();
		
		System.out.println(pop());
	}

}

