import java.util.*;

public class Main {
	public static void main(String[] args) {
		ALDS1_3_A();
	}

	public static void ALDS1_3_A() {
		Scanner sc = new Scanner(System.in);
		Deque<String> stack = new ArrayDeque<String>();
		while(sc.hasNext()) {
			String str = sc.next();
			if(str.equals("+")) {
				int a = Integer.parseInt(stack.removeFirst());
				int b = Integer.parseInt(stack.removeFirst());
				String c = Integer.toString(a + b);
				stack.addFirst(c);
			} else if(str.equals("-")) {
				int a = Integer.parseInt(stack.removeFirst());
				int b = Integer.parseInt(stack.removeFirst());
				String c = Integer.toString(b - a);
				stack.addFirst(c);
			} else if(str.equals("*")) {
				int a = Integer.parseInt(stack.removeFirst());
				int b = Integer.parseInt(stack.removeFirst());
				String c = Integer.toString(a * b);
				stack.addFirst(c);
			} else {
				stack.addFirst(str);
			}
		}
		
		System.out.println(stack.removeFirst());
	}
	
} import java.util.*; util.* java public class Main {
	public static void main(String[] args) {
		ALDS1_3_A();
	}

	public static void ALDS1_3_A() {
		Scanner sc = new Scanner(System.in);
		Deque<String> stack = new ArrayDeque<String>();
		while(sc.hasNext()) {
			String str = sc.next();
			if(str.equals("+")) {
				int a = Integer.parseInt(stack.removeFirst());
				int b = Integer.parseInt(stack.removeFirst());
				String c = Integer.toString(a + b);
				stack.addFirst(c);
			} else if(str.equals("-")) {
				int a = Integer.parseInt(stack.removeFirst());
				int b = Integer.parseInt(stack.removeFirst());
				String c = Integer.toString(b - a);
				stack.addFirst(c);
			} else if(str.equals("*")) {
				int a = Integer.parseInt(stack.removeFirst());
				int b = Integer.parseInt(stack.removeFirst());
				String c = Integer.toString(a * b);
				stack.addFirst(c);
			} else {
				stack.addFirst(str);
			}
		}
		
		System.out.println(stack.removeFirst());
	}
	
} Main public static void main(String[] args) {
		ALDS1_3_A();
	} main {
		ALDS1_3_A();
	} ALDS1_3_A() ALDS1_3_A String[] args args public static void ALDS1_3_A() {
		Scanner sc = new Scanner(System.in);
		Deque<String> stack = new ArrayDeque<String>();
		while(sc.hasNext()) {
			String str = sc.next();
			if(str.equals("+")) {
				int a = Integer.parseInt(stack.removeFirst());
				int b = Integer.parseInt(stack.removeFirst());
				String c = Integer.toString(a + b);
				stack.addFirst(c);
			} else if(str.equals("-")) {
				int a = Integer.parseInt(stack.removeFirst());
				int b = Integer.parseInt(stack.removeFirst());
				String c = Integer.toString(b - a);
				stack.addFirst(c);
			} else if(str.equals("*")) {
				int a = Integer.parseInt(stack.removeFirst());
				int b = Integer.parseInt(stack.removeFirst());
				String c = Integer.toString(a * b);
				stack.addFirst(c);
			} else {
				stack.addFirst(str);
			}
		}
		
		System.out.println(stack.removeFirst());
	} ALDS1_3_A {
		Scanner sc = new Scanner(System.in);
		Deque<String> stack = new ArrayDeque<String>();
		while(sc.hasNext()) {
			String str = sc.next();
			if(str.equals("+")) {
				int a = Integer.parseInt(stack.removeFirst());
				int b = Integer.parseInt(stack.removeFirst());
				String c = Integer.toString(a + b);
				stack.addFirst(c);
			} else if(str.equals("-")) {
				int a = Integer.parseInt(stack.removeFirst());
				int b = Integer.parseInt(stack.removeFirst());
				String c = Integer.toString(b - a);
				stack.addFirst(c);
			} else if(str.equals("*")) {
				int a = Integer.parseInt(stack.removeFirst());
				int b = Integer.parseInt(stack.removeFirst());
				String c = Integer.toString(a * b);
				stack.addFirst(c);
			} else {
				stack.addFirst(str);
			}
		}
		
		System.out.println(stack.removeFirst());
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) Deque<String> stack = new ArrayDeque<String>(); stack new ArrayDeque<String>() while(sc.hasNext()) {
			String str = sc.next();
			if(str.equals("+")) {
				int a = Integer.parseInt(stack.removeFirst());
				int b = Integer.parseInt(stack.removeFirst());
				String c = Integer.toString(a + b);
				stack.addFirst(c);
			} else if(str.equals("-")) {
				int a = Integer.parseInt(stack.removeFirst());
				int b = Integer.parseInt(stack.removeFirst());
				String c = Integer.toString(b - a);
				stack.addFirst(c);
			} else if(str.equals("*")) {
				int a = Integer.parseInt(stack.removeFirst());
				int b = Integer.parseInt(stack.removeFirst());
				String c = Integer.toString(a * b);
				stack.addFirst(c);
			} else {
				stack.addFirst(str);
			}
		} sc.hasNext() sc.hasNext sc {
			String str = sc.next();
			if(str.equals("+")) {
				int a = Integer.parseInt(stack.removeFirst());
				int b = Integer.parseInt(stack.removeFirst());
				String c = Integer.toString(a + b);
				stack.addFirst(c);
			} else if(str.equals("-")) {
				int a = Integer.parseInt(stack.removeFirst());
				int b = Integer.parseInt(stack.removeFirst());
				String c = Integer.toString(b - a);
				stack.addFirst(c);
			} else if(str.equals("*")) {
				int a = Integer.parseInt(stack.removeFirst());
				int b = Integer.parseInt(stack.removeFirst());
				String c = Integer.toString(a * b);
				stack.addFirst(c);
			} else {
				stack.addFirst(str);
			}
		} String str = sc.next(); str sc.next() sc.next sc if(str.equals("+")) {
				int a = Integer.parseInt(stack.removeFirst());
				int b = Integer.parseInt(stack.removeFirst());
				String c = Integer.toString(a + b);
				stack.addFirst(c);
			} else if(str.equals("-")) {
				int a = Integer.parseInt(stack.removeFirst());
				int b = Integer.parseInt(stack.removeFirst());
				String c = Integer.toString(b - a);
				stack.addFirst(c);
			} else if(str.equals("*")) {
				int a = Integer.parseInt(stack.removeFirst());
				int b = Integer.parseInt(stack.removeFirst());
				String c = Integer.toString(a * b);
				stack.addFirst(c);
			} else {
				stack.addFirst(str);
			} str.equals("+") str.equals str "+" {
				int a = Integer.parseInt(stack.removeFirst());
				int b = Integer.parseInt(stack.removeFirst());
				String c = Integer.toString(a + b);
				stack.addFirst(c);
			} int a = Integer.parseInt(stack.removeFirst()); a Integer.parseInt(stack.removeFirst()) Integer.parseInt Integer stack.removeFirst() stack.removeFirst stack int b = Integer.parseInt(stack.removeFirst()); b Integer.parseInt(stack.removeFirst()) Integer.parseInt Integer stack.removeFirst() stack.removeFirst stack String c = Integer.toString(a + b); c Integer.toString(a + b) Integer.toString Integer a + b a b stack.addFirst(c) stack.addFirst stack c if(str.equals("-")) {
				int a = Integer.parseInt(stack.removeFirst());
				int b = Integer.parseInt(stack.removeFirst());
				String c = Integer.toString(b - a);
				stack.addFirst(c);
			} else if(str.equals("*")) {
				int a = Integer.parseInt(stack.removeFirst());
				int b = Integer.parseInt(stack.removeFirst());
				String c = Integer.toString(a * b);
				stack.addFirst(c);
			} else {
				stack.addFirst(str);
			} str.equals("-") str.equals str "-" {
				int a = Integer.parseInt(stack.removeFirst());
				int b = Integer.parseInt(stack.removeFirst());
				String c = Integer.toString(b - a);
				stack.addFirst(c);
			} int a = Integer.parseInt(stack.removeFirst()); a Integer.parseInt(stack.removeFirst()) Integer.parseInt Integer stack.removeFirst() stack.removeFirst stack int b = Integer.parseInt(stack.removeFirst()); b Integer.parseInt(stack.removeFirst()) Integer.parseInt Integer stack.removeFirst() stack.removeFirst stack String c = Integer.toString(b - a); c Integer.toString(b - a) Integer.toString Integer b - a b a stack.addFirst(c) stack.addFirst stack c if(str.equals("*")) {
				int a = Integer.parseInt(stack.removeFirst());
				int b = Integer.parseInt(stack.removeFirst());
				String c = Integer.toString(a * b);
				stack.addFirst(c);
			} else {
				stack.addFirst(str);
			} str.equals("*") str.equals str "*" {
				int a = Integer.parseInt(stack.removeFirst());
				int b = Integer.parseInt(stack.removeFirst());
				String c = Integer.toString(a * b);
				stack.addFirst(c);
			} int a = Integer.parseInt(stack.removeFirst()); a Integer.parseInt(stack.removeFirst()) Integer.parseInt Integer stack.removeFirst() stack.removeFirst stack int b = Integer.parseInt(stack.removeFirst()); b Integer.parseInt(stack.removeFirst()) Integer.parseInt Integer stack.removeFirst() stack.removeFirst stack String c = Integer.toString(a * b); c Integer.toString(a * b) Integer.toString Integer a * b a b stack.addFirst(c) stack.addFirst stack c {
				stack.addFirst(str);
			} stack.addFirst(str) stack.addFirst stack str System.out.println(stack.removeFirst()) System.out.println System.out System System.out stack.removeFirst() stack.removeFirst stack public class Main {
	public static void main(String[] args) {
		ALDS1_3_A();
	}

	public static void ALDS1_3_A() {
		Scanner sc = new Scanner(System.in);
		Deque<String> stack = new ArrayDeque<String>();
		while(sc.hasNext()) {
			String str = sc.next();
			if(str.equals("+")) {
				int a = Integer.parseInt(stack.removeFirst());
				int b = Integer.parseInt(stack.removeFirst());
				String c = Integer.toString(a + b);
				stack.addFirst(c);
			} else if(str.equals("-")) {
				int a = Integer.parseInt(stack.removeFirst());
				int b = Integer.parseInt(stack.removeFirst());
				String c = Integer.toString(b - a);
				stack.addFirst(c);
			} else if(str.equals("*")) {
				int a = Integer.parseInt(stack.removeFirst());
				int b = Integer.parseInt(stack.removeFirst());
				String c = Integer.toString(a * b);
				stack.addFirst(c);
			} else {
				stack.addFirst(str);
			}
		}
		
		System.out.println(stack.removeFirst());
	}
	
} public class Main {
	public static void main(String[] args) {
		ALDS1_3_A();
	}

	public static void ALDS1_3_A() {
		Scanner sc = new Scanner(System.in);
		Deque<String> stack = new ArrayDeque<String>();
		while(sc.hasNext()) {
			String str = sc.next();
			if(str.equals("+")) {
				int a = Integer.parseInt(stack.removeFirst());
				int b = Integer.parseInt(stack.removeFirst());
				String c = Integer.toString(a + b);
				stack.addFirst(c);
			} else if(str.equals("-")) {
				int a = Integer.parseInt(stack.removeFirst());
				int b = Integer.parseInt(stack.removeFirst());
				String c = Integer.toString(b - a);
				stack.addFirst(c);
			} else if(str.equals("*")) {
				int a = Integer.parseInt(stack.removeFirst());
				int b = Integer.parseInt(stack.removeFirst());
				String c = Integer.toString(a * b);
				stack.addFirst(c);
			} else {
				stack.addFirst(str);
			}
		}
		
		System.out.println(stack.removeFirst());
	}
	
} Main
import java.util.*;

public class Main {
	public static void main(String[] args) {
		ALDS1_3_A();
	}

	public static void ALDS1_3_A() {
		Scanner sc = new Scanner(System.in);
		Deque<String> stack = new ArrayDeque<String>();
		while(sc.hasNext()) {
			String str = sc.next();
			if(str.equals("+")) {
				int a = Integer.parseInt(stack.removeFirst());
				int b = Integer.parseInt(stack.removeFirst());
				String c = Integer.toString(a + b);
				stack.addFirst(c);
			} else if(str.equals("-")) {
				int a = Integer.parseInt(stack.removeFirst());
				int b = Integer.parseInt(stack.removeFirst());
				String c = Integer.toString(b - a);
				stack.addFirst(c);
			} else if(str.equals("*")) {
				int a = Integer.parseInt(stack.removeFirst());
				int b = Integer.parseInt(stack.removeFirst());
				String c = Integer.toString(a * b);
				stack.addFirst(c);
			} else {
				stack.addFirst(str);
			}
		}
		
		System.out.println(stack.removeFirst());
	}
	
}
