import java.util.*;
import static java.lang.System.*;

public class Main {
	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		int a,b;
		String[] ar = sc.nextLine().split(" ");
		Deque<Integer> deque = new ArrayDeque<>();
		for (int i=0; i<ar.length; i++) {
			if (ar[i].equals("+")) {
				a = deque.removeFirst();
				b = deque.removeFirst();
				deque.addFirst(a+b);
			}
			else if (ar[i].equals("-")) {
				a = deque.removeFirst();
				b = deque.removeFirst();
				deque.addFirst(b-a);
			}
			else if (ar[i].equals("*")) {
				a = deque.removeFirst();
				b = deque.removeFirst();
				deque.addFirst(a*b);
			}
			else {
				deque.addFirst(Integer.parseInt(ar[i]));
			}
		}
		out.println(deque.getFirst());
	}
}
 import java.util.*; util.* java import static java.lang.System.*; import static java.lang.System.*; import static java.lang.System.*; public class Main {
	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		int a,b;
		String[] ar = sc.nextLine().split(" ");
		Deque<Integer> deque = new ArrayDeque<>();
		for (int i=0; i<ar.length; i++) {
			if (ar[i].equals("+")) {
				a = deque.removeFirst();
				b = deque.removeFirst();
				deque.addFirst(a+b);
			}
			else if (ar[i].equals("-")) {
				a = deque.removeFirst();
				b = deque.removeFirst();
				deque.addFirst(b-a);
			}
			else if (ar[i].equals("*")) {
				a = deque.removeFirst();
				b = deque.removeFirst();
				deque.addFirst(a*b);
			}
			else {
				deque.addFirst(Integer.parseInt(ar[i]));
			}
		}
		out.println(deque.getFirst());
	}
} Main static Scanner sc = new Scanner(System.in); sc new Scanner(System.in) public static void main(String[] args) {
		int a,b;
		String[] ar = sc.nextLine().split(" ");
		Deque<Integer> deque = new ArrayDeque<>();
		for (int i=0; i<ar.length; i++) {
			if (ar[i].equals("+")) {
				a = deque.removeFirst();
				b = deque.removeFirst();
				deque.addFirst(a+b);
			}
			else if (ar[i].equals("-")) {
				a = deque.removeFirst();
				b = deque.removeFirst();
				deque.addFirst(b-a);
			}
			else if (ar[i].equals("*")) {
				a = deque.removeFirst();
				b = deque.removeFirst();
				deque.addFirst(a*b);
			}
			else {
				deque.addFirst(Integer.parseInt(ar[i]));
			}
		}
		out.println(deque.getFirst());
	} main {
		int a,b;
		String[] ar = sc.nextLine().split(" ");
		Deque<Integer> deque = new ArrayDeque<>();
		for (int i=0; i<ar.length; i++) {
			if (ar[i].equals("+")) {
				a = deque.removeFirst();
				b = deque.removeFirst();
				deque.addFirst(a+b);
			}
			else if (ar[i].equals("-")) {
				a = deque.removeFirst();
				b = deque.removeFirst();
				deque.addFirst(b-a);
			}
			else if (ar[i].equals("*")) {
				a = deque.removeFirst();
				b = deque.removeFirst();
				deque.addFirst(a*b);
			}
			else {
				deque.addFirst(Integer.parseInt(ar[i]));
			}
		}
		out.println(deque.getFirst());
	} int a a b; b String[] ar = sc.nextLine().split(" "); ar sc.nextLine().split(" ") sc.nextLine().split sc.nextLine() sc.nextLine sc " " Deque<Integer> deque = new ArrayDeque<>(); deque new ArrayDeque<>() for (int i=0; i<ar.length; i++) {
			if (ar[i].equals("+")) {
				a = deque.removeFirst();
				b = deque.removeFirst();
				deque.addFirst(a+b);
			}
			else if (ar[i].equals("-")) {
				a = deque.removeFirst();
				b = deque.removeFirst();
				deque.addFirst(b-a);
			}
			else if (ar[i].equals("*")) {
				a = deque.removeFirst();
				b = deque.removeFirst();
				deque.addFirst(a*b);
			}
			else {
				deque.addFirst(Integer.parseInt(ar[i]));
			}
		} int i=0; int i=0; i 0 i<ar.length i ar.length ar ar.length i++ i++ i {
			if (ar[i].equals("+")) {
				a = deque.removeFirst();
				b = deque.removeFirst();
				deque.addFirst(a+b);
			}
			else if (ar[i].equals("-")) {
				a = deque.removeFirst();
				b = deque.removeFirst();
				deque.addFirst(b-a);
			}
			else if (ar[i].equals("*")) {
				a = deque.removeFirst();
				b = deque.removeFirst();
				deque.addFirst(a*b);
			}
			else {
				deque.addFirst(Integer.parseInt(ar[i]));
			}
		} {
			if (ar[i].equals("+")) {
				a = deque.removeFirst();
				b = deque.removeFirst();
				deque.addFirst(a+b);
			}
			else if (ar[i].equals("-")) {
				a = deque.removeFirst();
				b = deque.removeFirst();
				deque.addFirst(b-a);
			}
			else if (ar[i].equals("*")) {
				a = deque.removeFirst();
				b = deque.removeFirst();
				deque.addFirst(a*b);
			}
			else {
				deque.addFirst(Integer.parseInt(ar[i]));
			}
		} if (ar[i].equals("+")) {
				a = deque.removeFirst();
				b = deque.removeFirst();
				deque.addFirst(a+b);
			}
			else if (ar[i].equals("-")) {
				a = deque.removeFirst();
				b = deque.removeFirst();
				deque.addFirst(b-a);
			}
			else if (ar[i].equals("*")) {
				a = deque.removeFirst();
				b = deque.removeFirst();
				deque.addFirst(a*b);
			}
			else {
				deque.addFirst(Integer.parseInt(ar[i]));
			} ar[i].equals("+") ar[i].equals ar[i] ar i "+" {
				a = deque.removeFirst();
				b = deque.removeFirst();
				deque.addFirst(a+b);
			} a = deque.removeFirst() a deque.removeFirst() deque.removeFirst deque b = deque.removeFirst() b deque.removeFirst() deque.removeFirst deque deque.addFirst(a+b) deque.addFirst deque a+b a b if (ar[i].equals("-")) {
				a = deque.removeFirst();
				b = deque.removeFirst();
				deque.addFirst(b-a);
			}
			else if (ar[i].equals("*")) {
				a = deque.removeFirst();
				b = deque.removeFirst();
				deque.addFirst(a*b);
			}
			else {
				deque.addFirst(Integer.parseInt(ar[i]));
			} ar[i].equals("-") ar[i].equals ar[i] ar i "-" {
				a = deque.removeFirst();
				b = deque.removeFirst();
				deque.addFirst(b-a);
			} a = deque.removeFirst() a deque.removeFirst() deque.removeFirst deque b = deque.removeFirst() b deque.removeFirst() deque.removeFirst deque deque.addFirst(b-a) deque.addFirst deque b-a b a if (ar[i].equals("*")) {
				a = deque.removeFirst();
				b = deque.removeFirst();
				deque.addFirst(a*b);
			}
			else {
				deque.addFirst(Integer.parseInt(ar[i]));
			} ar[i].equals("*") ar[i].equals ar[i] ar i "*" {
				a = deque.removeFirst();
				b = deque.removeFirst();
				deque.addFirst(a*b);
			} a = deque.removeFirst() a deque.removeFirst() deque.removeFirst deque b = deque.removeFirst() b deque.removeFirst() deque.removeFirst deque deque.addFirst(a*b) deque.addFirst deque a*b a b {
				deque.addFirst(Integer.parseInt(ar[i]));
			} deque.addFirst(Integer.parseInt(ar[i])) deque.addFirst deque Integer.parseInt(ar[i]) Integer.parseInt Integer ar[i] ar i out.println(deque.getFirst()) out.println out deque.getFirst() deque.getFirst deque String[] args args public class Main {
	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		int a,b;
		String[] ar = sc.nextLine().split(" ");
		Deque<Integer> deque = new ArrayDeque<>();
		for (int i=0; i<ar.length; i++) {
			if (ar[i].equals("+")) {
				a = deque.removeFirst();
				b = deque.removeFirst();
				deque.addFirst(a+b);
			}
			else if (ar[i].equals("-")) {
				a = deque.removeFirst();
				b = deque.removeFirst();
				deque.addFirst(b-a);
			}
			else if (ar[i].equals("*")) {
				a = deque.removeFirst();
				b = deque.removeFirst();
				deque.addFirst(a*b);
			}
			else {
				deque.addFirst(Integer.parseInt(ar[i]));
			}
		}
		out.println(deque.getFirst());
	}
} public class Main {
	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		int a,b;
		String[] ar = sc.nextLine().split(" ");
		Deque<Integer> deque = new ArrayDeque<>();
		for (int i=0; i<ar.length; i++) {
			if (ar[i].equals("+")) {
				a = deque.removeFirst();
				b = deque.removeFirst();
				deque.addFirst(a+b);
			}
			else if (ar[i].equals("-")) {
				a = deque.removeFirst();
				b = deque.removeFirst();
				deque.addFirst(b-a);
			}
			else if (ar[i].equals("*")) {
				a = deque.removeFirst();
				b = deque.removeFirst();
				deque.addFirst(a*b);
			}
			else {
				deque.addFirst(Integer.parseInt(ar[i]));
			}
		}
		out.println(deque.getFirst());
	}
} Main
import java.util.*;
import static java.lang.System.*;

public class Main {
	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		int a,b;
		String[] ar = sc.nextLine().split(" ");
		Deque<Integer> deque = new ArrayDeque<>();
		for (int i=0; i<ar.length; i++) {
			if (ar[i].equals("+")) {
				a = deque.removeFirst();
				b = deque.removeFirst();
				deque.addFirst(a+b);
			}
			else if (ar[i].equals("-")) {
				a = deque.removeFirst();
				b = deque.removeFirst();
				deque.addFirst(b-a);
			}
			else if (ar[i].equals("*")) {
				a = deque.removeFirst();
				b = deque.removeFirst();
				deque.addFirst(a*b);
			}
			else {
				deque.addFirst(Integer.parseInt(ar[i]));
			}
		}
		out.println(deque.getFirst());
	}
}

