import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);

		String[] stack;
		String line = stdIn.nextLine();
		stack = line.split(" ", 0);

		Stack stack1 = new Stack();

		for (int i = 0; i < stack.length; i++) {
			int tmp = 0;
			switch (stack[i]) {
				case "+":{
					tmp = stack1.pop() + stack1.pop();
					stack1.push(String.valueOf(tmp));
					break;
				}

				/*????????§??????????????§???*/
				case "-":{
					int operand1 = stack1.pop();
					int operand2 = stack1.pop();
					tmp = operand2 - operand1;
					stack1.push(String.valueOf(tmp));
					break;
				}
				case "*":{
					tmp = stack1.pop() * stack1.pop();
					stack1.push(String.valueOf(tmp));
					break;
				}
				default:{
					stack1.push(stack[i]);
					break;
				}
			}
		}
		System.out.println(stack1.pop());

	}
}

class Stack{
	int maxSize = 200;
	int pointer;
	String[] stack = new String[maxSize];

	public void initialize(){
		this.pointer = 0;
	}

	public void push(String x) {
		this.stack[pointer] = x;
		pointer++;
	}

	public int pop() {
		pointer--;
		return Integer.parseInt(stack[pointer]);
	}

} import java.util.*; util.* java class Main {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);

		String[] stack;
		String line = stdIn.nextLine();
		stack = line.split(" ", 0);

		Stack stack1 = new Stack();

		for (int i = 0; i < stack.length; i++) {
			int tmp = 0;
			switch (stack[i]) {
				case "+":{
					tmp = stack1.pop() + stack1.pop();
					stack1.push(String.valueOf(tmp));
					break;
				}

				/*????????§??????????????§???*/
				case "-":{
					int operand1 = stack1.pop();
					int operand2 = stack1.pop();
					tmp = operand2 - operand1;
					stack1.push(String.valueOf(tmp));
					break;
				}
				case "*":{
					tmp = stack1.pop() * stack1.pop();
					stack1.push(String.valueOf(tmp));
					break;
				}
				default:{
					stack1.push(stack[i]);
					break;
				}
			}
		}
		System.out.println(stack1.pop());

	}
} Main public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);

		String[] stack;
		String line = stdIn.nextLine();
		stack = line.split(" ", 0);

		Stack stack1 = new Stack();

		for (int i = 0; i < stack.length; i++) {
			int tmp = 0;
			switch (stack[i]) {
				case "+":{
					tmp = stack1.pop() + stack1.pop();
					stack1.push(String.valueOf(tmp));
					break;
				}

				/*????????§??????????????§???*/
				case "-":{
					int operand1 = stack1.pop();
					int operand2 = stack1.pop();
					tmp = operand2 - operand1;
					stack1.push(String.valueOf(tmp));
					break;
				}
				case "*":{
					tmp = stack1.pop() * stack1.pop();
					stack1.push(String.valueOf(tmp));
					break;
				}
				default:{
					stack1.push(stack[i]);
					break;
				}
			}
		}
		System.out.println(stack1.pop());

	} main {
		Scanner stdIn = new Scanner(System.in);

		String[] stack;
		String line = stdIn.nextLine();
		stack = line.split(" ", 0);

		Stack stack1 = new Stack();

		for (int i = 0; i < stack.length; i++) {
			int tmp = 0;
			switch (stack[i]) {
				case "+":{
					tmp = stack1.pop() + stack1.pop();
					stack1.push(String.valueOf(tmp));
					break;
				}

				/*????????§??????????????§???*/
				case "-":{
					int operand1 = stack1.pop();
					int operand2 = stack1.pop();
					tmp = operand2 - operand1;
					stack1.push(String.valueOf(tmp));
					break;
				}
				case "*":{
					tmp = stack1.pop() * stack1.pop();
					stack1.push(String.valueOf(tmp));
					break;
				}
				default:{
					stack1.push(stack[i]);
					break;
				}
			}
		}
		System.out.println(stack1.pop());

	} Scanner stdIn = new Scanner(System.in); stdIn new Scanner(System.in) String[] stack; stack String line = stdIn.nextLine(); line stdIn.nextLine() stdIn.nextLine stdIn stack = line.split(" ", 0) stack line.split(" ", 0) line.split line " " 0 Stack stack1 = new Stack(); stack1 new Stack() for (int i = 0; i < stack.length; i++) {
			int tmp = 0;
			switch (stack[i]) {
				case "+":{
					tmp = stack1.pop() + stack1.pop();
					stack1.push(String.valueOf(tmp));
					break;
				}

				/*????????§??????????????§???*/
				case "-":{
					int operand1 = stack1.pop();
					int operand2 = stack1.pop();
					tmp = operand2 - operand1;
					stack1.push(String.valueOf(tmp));
					break;
				}
				case "*":{
					tmp = stack1.pop() * stack1.pop();
					stack1.push(String.valueOf(tmp));
					break;
				}
				default:{
					stack1.push(stack[i]);
					break;
				}
			}
		} int i = 0; int i = 0; i 0 i < stack.length i stack.length stack stack.length i++ i++ i {
			int tmp = 0;
			switch (stack[i]) {
				case "+":{
					tmp = stack1.pop() + stack1.pop();
					stack1.push(String.valueOf(tmp));
					break;
				}

				/*????????§??????????????§???*/
				case "-":{
					int operand1 = stack1.pop();
					int operand2 = stack1.pop();
					tmp = operand2 - operand1;
					stack1.push(String.valueOf(tmp));
					break;
				}
				case "*":{
					tmp = stack1.pop() * stack1.pop();
					stack1.push(String.valueOf(tmp));
					break;
				}
				default:{
					stack1.push(stack[i]);
					break;
				}
			}
		} {
			int tmp = 0;
			switch (stack[i]) {
				case "+":{
					tmp = stack1.pop() + stack1.pop();
					stack1.push(String.valueOf(tmp));
					break;
				}

				/*????????§??????????????§???*/
				case "-":{
					int operand1 = stack1.pop();
					int operand2 = stack1.pop();
					tmp = operand2 - operand1;
					stack1.push(String.valueOf(tmp));
					break;
				}
				case "*":{
					tmp = stack1.pop() * stack1.pop();
					stack1.push(String.valueOf(tmp));
					break;
				}
				default:{
					stack1.push(stack[i]);
					break;
				}
			}
		} int tmp = 0; tmp 0 switch (stack[i]) {
				case "+":{
					tmp = stack1.pop() + stack1.pop();
					stack1.push(String.valueOf(tmp));
					break;
				}

				/*????????§??????????????§???*/
				case "-":{
					int operand1 = stack1.pop();
					int operand2 = stack1.pop();
					tmp = operand2 - operand1;
					stack1.push(String.valueOf(tmp));
					break;
				}
				case "*":{
					tmp = stack1.pop() * stack1.pop();
					stack1.push(String.valueOf(tmp));
					break;
				}
				default:{
					stack1.push(stack[i]);
					break;
				}
			} stack[i] stack i case "+": "+" case "+": {
					tmp = stack1.pop() + stack1.pop();
					stack1.push(String.valueOf(tmp));
					break;
				} tmp = stack1.pop() + stack1.pop() tmp stack1.pop() + stack1.pop() stack1.pop() stack1.pop stack1 stack1.pop() stack1.pop stack1 stack1.push(String.valueOf(tmp)) stack1.push stack1 String.valueOf(tmp) String.valueOf String tmp break; case "-": "-" case "-": {
					int operand1 = stack1.pop();
					int operand2 = stack1.pop();
					tmp = operand2 - operand1;
					stack1.push(String.valueOf(tmp));
					break;
				} int operand1 = stack1.pop(); operand1 stack1.pop() stack1.pop stack1 int operand2 = stack1.pop(); operand2 stack1.pop() stack1.pop stack1 tmp = operand2 - operand1 tmp operand2 - operand1 operand2 operand1 stack1.push(String.valueOf(tmp)) stack1.push stack1 String.valueOf(tmp) String.valueOf String tmp break; case "*": "*" case "*": {
					tmp = stack1.pop() * stack1.pop();
					stack1.push(String.valueOf(tmp));
					break;
				} tmp = stack1.pop() * stack1.pop() tmp stack1.pop() * stack1.pop() stack1.pop() stack1.pop stack1 stack1.pop() stack1.pop stack1 stack1.push(String.valueOf(tmp)) stack1.push stack1 String.valueOf(tmp) String.valueOf String tmp break; default: default: {
					stack1.push(stack[i]);
					break;
				} stack1.push(stack[i]) stack1.push stack1 stack[i] stack i break; System.out.println(stack1.pop()) System.out.println System.out System System.out stack1.pop() stack1.pop stack1 String[] args args class Stack{
	int maxSize = 200;
	int pointer;
	String[] stack = new String[maxSize];

	public void initialize(){
		this.pointer = 0;
	}

	public void push(String x) {
		this.stack[pointer] = x;
		pointer++;
	}

	public int pop() {
		pointer--;
		return Integer.parseInt(stack[pointer]);
	}

} Stack int maxSize = 200; maxSize 200 int pointer; pointer String[] stack = new String[maxSize]; stack new String[maxSize] maxSize public void initialize(){
		this.pointer = 0;
	} initialize {
		this.pointer = 0;
	} this.pointer = 0 this.pointer this this.pointer 0 public void push(String x) {
		this.stack[pointer] = x;
		pointer++;
	} push {
		this.stack[pointer] = x;
		pointer++;
	} this.stack[pointer] = x this.stack[pointer] this.stack this this.stack pointer x pointer++ pointer String x x public int pop() {
		pointer--;
		return Integer.parseInt(stack[pointer]);
	} pop {
		pointer--;
		return Integer.parseInt(stack[pointer]);
	} pointer-- pointer return Integer.parseInt(stack[pointer]); Integer.parseInt(stack[pointer]) Integer.parseInt Integer stack[pointer] stack pointer
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);

		String[] stack;
		String line = stdIn.nextLine();
		stack = line.split(" ", 0);

		Stack stack1 = new Stack();

		for (int i = 0; i < stack.length; i++) {
			int tmp = 0;
			switch (stack[i]) {
				case "+":{
					tmp = stack1.pop() + stack1.pop();
					stack1.push(String.valueOf(tmp));
					break;
				}

				/*????????§??????????????§???*/
				case "-":{
					int operand1 = stack1.pop();
					int operand2 = stack1.pop();
					tmp = operand2 - operand1;
					stack1.push(String.valueOf(tmp));
					break;
				}
				case "*":{
					tmp = stack1.pop() * stack1.pop();
					stack1.push(String.valueOf(tmp));
					break;
				}
				default:{
					stack1.push(stack[i]);
					break;
				}
			}
		}
		System.out.println(stack1.pop());

	}
}

class Stack{
	int maxSize = 200;
	int pointer;
	String[] stack = new String[maxSize];

	public void initialize(){
		this.pointer = 0;
	}

	public void push(String x) {
		this.stack[pointer] = x;
		pointer++;
	}

	public int pop() {
		pointer--;
		return Integer.parseInt(stack[pointer]);
	}

}