import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		String[] str = stdIn.nextLine().split(" ");
		Deque<Integer> stack = new LinkedList<Integer>();

		for (int i=0; i<str.length; i++) {
			char c = str[i].charAt(0);
			if(c>='0' && c<='9'){
				stack.add(Integer.parseInt(str[i]));
			}else {
				int x = stack.pollLast();
				int y = stack.pollLast();
				switch(c){
					case '+':stack.add(x+y); break;
					case '-':stack.add(y-x); break;
					case '*':stack.add(x*y); break;
				}
			}
		}

		System.out.println(stack.poll());
	}
} import java.util.*; util.* java class Main {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		String[] str = stdIn.nextLine().split(" ");
		Deque<Integer> stack = new LinkedList<Integer>();

		for (int i=0; i<str.length; i++) {
			char c = str[i].charAt(0);
			if(c>='0' && c<='9'){
				stack.add(Integer.parseInt(str[i]));
			}else {
				int x = stack.pollLast();
				int y = stack.pollLast();
				switch(c){
					case '+':stack.add(x+y); break;
					case '-':stack.add(y-x); break;
					case '*':stack.add(x*y); break;
				}
			}
		}

		System.out.println(stack.poll());
	}
} Main public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		String[] str = stdIn.nextLine().split(" ");
		Deque<Integer> stack = new LinkedList<Integer>();

		for (int i=0; i<str.length; i++) {
			char c = str[i].charAt(0);
			if(c>='0' && c<='9'){
				stack.add(Integer.parseInt(str[i]));
			}else {
				int x = stack.pollLast();
				int y = stack.pollLast();
				switch(c){
					case '+':stack.add(x+y); break;
					case '-':stack.add(y-x); break;
					case '*':stack.add(x*y); break;
				}
			}
		}

		System.out.println(stack.poll());
	} main {
		Scanner stdIn = new Scanner(System.in);
		String[] str = stdIn.nextLine().split(" ");
		Deque<Integer> stack = new LinkedList<Integer>();

		for (int i=0; i<str.length; i++) {
			char c = str[i].charAt(0);
			if(c>='0' && c<='9'){
				stack.add(Integer.parseInt(str[i]));
			}else {
				int x = stack.pollLast();
				int y = stack.pollLast();
				switch(c){
					case '+':stack.add(x+y); break;
					case '-':stack.add(y-x); break;
					case '*':stack.add(x*y); break;
				}
			}
		}

		System.out.println(stack.poll());
	} Scanner stdIn = new Scanner(System.in); stdIn new Scanner(System.in) String[] str = stdIn.nextLine().split(" "); str stdIn.nextLine().split(" ") stdIn.nextLine().split stdIn.nextLine() stdIn.nextLine stdIn " " Deque<Integer> stack = new LinkedList<Integer>(); stack new LinkedList<Integer>() for (int i=0; i<str.length; i++) {
			char c = str[i].charAt(0);
			if(c>='0' && c<='9'){
				stack.add(Integer.parseInt(str[i]));
			}else {
				int x = stack.pollLast();
				int y = stack.pollLast();
				switch(c){
					case '+':stack.add(x+y); break;
					case '-':stack.add(y-x); break;
					case '*':stack.add(x*y); break;
				}
			}
		} int i=0; int i=0; i 0 i<str.length i str.length str str.length i++ i++ i {
			char c = str[i].charAt(0);
			if(c>='0' && c<='9'){
				stack.add(Integer.parseInt(str[i]));
			}else {
				int x = stack.pollLast();
				int y = stack.pollLast();
				switch(c){
					case '+':stack.add(x+y); break;
					case '-':stack.add(y-x); break;
					case '*':stack.add(x*y); break;
				}
			}
		} {
			char c = str[i].charAt(0);
			if(c>='0' && c<='9'){
				stack.add(Integer.parseInt(str[i]));
			}else {
				int x = stack.pollLast();
				int y = stack.pollLast();
				switch(c){
					case '+':stack.add(x+y); break;
					case '-':stack.add(y-x); break;
					case '*':stack.add(x*y); break;
				}
			}
		} char c = str[i].charAt(0); c str[i].charAt(0) str[i].charAt str[i] str i 0 if(c>='0' && c<='9'){
				stack.add(Integer.parseInt(str[i]));
			}else {
				int x = stack.pollLast();
				int y = stack.pollLast();
				switch(c){
					case '+':stack.add(x+y); break;
					case '-':stack.add(y-x); break;
					case '*':stack.add(x*y); break;
				}
			} c>='0' && c<='9' c>='0' c '0' c<='9' c '9' {
				stack.add(Integer.parseInt(str[i]));
			} stack.add(Integer.parseInt(str[i])) stack.add stack Integer.parseInt(str[i]) Integer.parseInt Integer str[i] str i {
				int x = stack.pollLast();
				int y = stack.pollLast();
				switch(c){
					case '+':stack.add(x+y); break;
					case '-':stack.add(y-x); break;
					case '*':stack.add(x*y); break;
				}
			} int x = stack.pollLast(); x stack.pollLast() stack.pollLast stack int y = stack.pollLast(); y stack.pollLast() stack.pollLast stack switch(c){
					case '+':stack.add(x+y); break;
					case '-':stack.add(y-x); break;
					case '*':stack.add(x*y); break;
				} c case '+': '+' case '+': stack.add(x+y) stack.add stack x+y x y break; case '-': '-' case '-': stack.add(y-x) stack.add stack y-x y x break; case '*': '*' case '*': stack.add(x*y) stack.add stack x*y x y break; System.out.println(stack.poll()) System.out.println System.out System System.out stack.poll() stack.poll stack String[] args args
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		String[] str = stdIn.nextLine().split(" ");
		Deque<Integer> stack = new LinkedList<Integer>();

		for (int i=0; i<str.length; i++) {
			char c = str[i].charAt(0);
			if(c>='0' && c<='9'){
				stack.add(Integer.parseInt(str[i]));
			}else {
				int x = stack.pollLast();
				int y = stack.pollLast();
				switch(c){
					case '+':stack.add(x+y); break;
					case '-':stack.add(y-x); break;
					case '*':stack.add(x*y); break;
				}
			}
		}

		System.out.println(stack.poll());
	}
}