import java.util.ArrayDeque;
import java.util.Deque;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		Deque<Integer> dc = new ArrayDeque<Integer>();
        
		while(scan.hasNext()) {
			String s = scan.next();
			if("+".equals(s)) {
				int x = dc.pop();
				int y = dc.pop();
				dc.push(x+y);
			}
			else if("-".equals(s)) {
				int x = dc.pop();
				int y = dc.pop();
				dc.push(y-x);
			}
			else if("*".equals(s)) {
				int x = dc.pop();
				int y = dc.pop();
				dc.push(x*y);
			}
			else {
				dc.push(Integer.valueOf(s));
			}
		}
		System.out.println(dc.pop());
		scan.close();
	}
} import java.util.ArrayDeque; ArrayDeque java.util import java.util.Deque; Deque java.util import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		Deque<Integer> dc = new ArrayDeque<Integer>();
        
		while(scan.hasNext()) {
			String s = scan.next();
			if("+".equals(s)) {
				int x = dc.pop();
				int y = dc.pop();
				dc.push(x+y);
			}
			else if("-".equals(s)) {
				int x = dc.pop();
				int y = dc.pop();
				dc.push(y-x);
			}
			else if("*".equals(s)) {
				int x = dc.pop();
				int y = dc.pop();
				dc.push(x*y);
			}
			else {
				dc.push(Integer.valueOf(s));
			}
		}
		System.out.println(dc.pop());
		scan.close();
	}
} Main public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		Deque<Integer> dc = new ArrayDeque<Integer>();
        
		while(scan.hasNext()) {
			String s = scan.next();
			if("+".equals(s)) {
				int x = dc.pop();
				int y = dc.pop();
				dc.push(x+y);
			}
			else if("-".equals(s)) {
				int x = dc.pop();
				int y = dc.pop();
				dc.push(y-x);
			}
			else if("*".equals(s)) {
				int x = dc.pop();
				int y = dc.pop();
				dc.push(x*y);
			}
			else {
				dc.push(Integer.valueOf(s));
			}
		}
		System.out.println(dc.pop());
		scan.close();
	} main {
		Scanner scan = new Scanner(System.in);
		Deque<Integer> dc = new ArrayDeque<Integer>();
        
		while(scan.hasNext()) {
			String s = scan.next();
			if("+".equals(s)) {
				int x = dc.pop();
				int y = dc.pop();
				dc.push(x+y);
			}
			else if("-".equals(s)) {
				int x = dc.pop();
				int y = dc.pop();
				dc.push(y-x);
			}
			else if("*".equals(s)) {
				int x = dc.pop();
				int y = dc.pop();
				dc.push(x*y);
			}
			else {
				dc.push(Integer.valueOf(s));
			}
		}
		System.out.println(dc.pop());
		scan.close();
	} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) Deque<Integer> dc = new ArrayDeque<Integer>(); dc new ArrayDeque<Integer>() while(scan.hasNext()) {
			String s = scan.next();
			if("+".equals(s)) {
				int x = dc.pop();
				int y = dc.pop();
				dc.push(x+y);
			}
			else if("-".equals(s)) {
				int x = dc.pop();
				int y = dc.pop();
				dc.push(y-x);
			}
			else if("*".equals(s)) {
				int x = dc.pop();
				int y = dc.pop();
				dc.push(x*y);
			}
			else {
				dc.push(Integer.valueOf(s));
			}
		} scan.hasNext() scan.hasNext scan {
			String s = scan.next();
			if("+".equals(s)) {
				int x = dc.pop();
				int y = dc.pop();
				dc.push(x+y);
			}
			else if("-".equals(s)) {
				int x = dc.pop();
				int y = dc.pop();
				dc.push(y-x);
			}
			else if("*".equals(s)) {
				int x = dc.pop();
				int y = dc.pop();
				dc.push(x*y);
			}
			else {
				dc.push(Integer.valueOf(s));
			}
		} String s = scan.next(); s scan.next() scan.next scan if("+".equals(s)) {
				int x = dc.pop();
				int y = dc.pop();
				dc.push(x+y);
			}
			else if("-".equals(s)) {
				int x = dc.pop();
				int y = dc.pop();
				dc.push(y-x);
			}
			else if("*".equals(s)) {
				int x = dc.pop();
				int y = dc.pop();
				dc.push(x*y);
			}
			else {
				dc.push(Integer.valueOf(s));
			} "+".equals(s) "+".equals "+" s {
				int x = dc.pop();
				int y = dc.pop();
				dc.push(x+y);
			} int x = dc.pop(); x dc.pop() dc.pop dc int y = dc.pop(); y dc.pop() dc.pop dc dc.push(x+y) dc.push dc x+y x y if("-".equals(s)) {
				int x = dc.pop();
				int y = dc.pop();
				dc.push(y-x);
			}
			else if("*".equals(s)) {
				int x = dc.pop();
				int y = dc.pop();
				dc.push(x*y);
			}
			else {
				dc.push(Integer.valueOf(s));
			} "-".equals(s) "-".equals "-" s {
				int x = dc.pop();
				int y = dc.pop();
				dc.push(y-x);
			} int x = dc.pop(); x dc.pop() dc.pop dc int y = dc.pop(); y dc.pop() dc.pop dc dc.push(y-x) dc.push dc y-x y x if("*".equals(s)) {
				int x = dc.pop();
				int y = dc.pop();
				dc.push(x*y);
			}
			else {
				dc.push(Integer.valueOf(s));
			} "*".equals(s) "*".equals "*" s {
				int x = dc.pop();
				int y = dc.pop();
				dc.push(x*y);
			} int x = dc.pop(); x dc.pop() dc.pop dc int y = dc.pop(); y dc.pop() dc.pop dc dc.push(x*y) dc.push dc x*y x y {
				dc.push(Integer.valueOf(s));
			} dc.push(Integer.valueOf(s)) dc.push dc Integer.valueOf(s) Integer.valueOf Integer s System.out.println(dc.pop()) System.out.println System.out System System.out dc.pop() dc.pop dc scan.close() scan.close scan String[] args args public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		Deque<Integer> dc = new ArrayDeque<Integer>();
        
		while(scan.hasNext()) {
			String s = scan.next();
			if("+".equals(s)) {
				int x = dc.pop();
				int y = dc.pop();
				dc.push(x+y);
			}
			else if("-".equals(s)) {
				int x = dc.pop();
				int y = dc.pop();
				dc.push(y-x);
			}
			else if("*".equals(s)) {
				int x = dc.pop();
				int y = dc.pop();
				dc.push(x*y);
			}
			else {
				dc.push(Integer.valueOf(s));
			}
		}
		System.out.println(dc.pop());
		scan.close();
	}
} public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		Deque<Integer> dc = new ArrayDeque<Integer>();
        
		while(scan.hasNext()) {
			String s = scan.next();
			if("+".equals(s)) {
				int x = dc.pop();
				int y = dc.pop();
				dc.push(x+y);
			}
			else if("-".equals(s)) {
				int x = dc.pop();
				int y = dc.pop();
				dc.push(y-x);
			}
			else if("*".equals(s)) {
				int x = dc.pop();
				int y = dc.pop();
				dc.push(x*y);
			}
			else {
				dc.push(Integer.valueOf(s));
			}
		}
		System.out.println(dc.pop());
		scan.close();
	}
} Main
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		Deque<Integer> dc = new ArrayDeque<Integer>();
        
		while(scan.hasNext()) {
			String s = scan.next();
			if("+".equals(s)) {
				int x = dc.pop();
				int y = dc.pop();
				dc.push(x+y);
			}
			else if("-".equals(s)) {
				int x = dc.pop();
				int y = dc.pop();
				dc.push(y-x);
			}
			else if("*".equals(s)) {
				int x = dc.pop();
				int y = dc.pop();
				dc.push(x*y);
			}
			else {
				dc.push(Integer.valueOf(s));
			}
		}
		System.out.println(dc.pop());
		scan.close();
	}
}
