import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main{

	public static void main(String[] args) throws IOException {
		int num1 = 0;
		int num2 = 0;
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String strArray[] = (br.readLine()).split(" ");
		Stack stack = new Stack(strArray.length);
		for(int i = 0;i < strArray.length; i++){
			if(strArray[i].equals("+")){
				num1 = stack.pop();
				num2 = stack.pop();
				stack.push(num1 + num2);
			}
			else if(strArray[i].equals("*")){
				num1 = stack.pop();
				num2 = stack.pop();
				stack.push(num1 * num2);
			}
			else if(strArray[i].equals("-")){
				num1 = stack.pop();
				num2 = stack.pop();
				stack.push(num2 - num1);
			}
			else{
				stack.push(Integer.parseInt(strArray[i]));
			}
		}
		System.out.println(stack.pop());
	}

}

class Stack{
	private int top;
	private int stack[];

	Stack(int size){
		stack = new int [size];
		top = 0;
	}

	public int pop(){
		return stack[--top];
	}

	public void push(int num){
		stack[top++] = num;
	}
} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io public class Main{

	public static void main(String[] args) throws IOException {
		int num1 = 0;
		int num2 = 0;
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String strArray[] = (br.readLine()).split(" ");
		Stack stack = new Stack(strArray.length);
		for(int i = 0;i < strArray.length; i++){
			if(strArray[i].equals("+")){
				num1 = stack.pop();
				num2 = stack.pop();
				stack.push(num1 + num2);
			}
			else if(strArray[i].equals("*")){
				num1 = stack.pop();
				num2 = stack.pop();
				stack.push(num1 * num2);
			}
			else if(strArray[i].equals("-")){
				num1 = stack.pop();
				num2 = stack.pop();
				stack.push(num2 - num1);
			}
			else{
				stack.push(Integer.parseInt(strArray[i]));
			}
		}
		System.out.println(stack.pop());
	}

} Main public static void main(String[] args) throws IOException {
		int num1 = 0;
		int num2 = 0;
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String strArray[] = (br.readLine()).split(" ");
		Stack stack = new Stack(strArray.length);
		for(int i = 0;i < strArray.length; i++){
			if(strArray[i].equals("+")){
				num1 = stack.pop();
				num2 = stack.pop();
				stack.push(num1 + num2);
			}
			else if(strArray[i].equals("*")){
				num1 = stack.pop();
				num2 = stack.pop();
				stack.push(num1 * num2);
			}
			else if(strArray[i].equals("-")){
				num1 = stack.pop();
				num2 = stack.pop();
				stack.push(num2 - num1);
			}
			else{
				stack.push(Integer.parseInt(strArray[i]));
			}
		}
		System.out.println(stack.pop());
	} main {
		int num1 = 0;
		int num2 = 0;
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String strArray[] = (br.readLine()).split(" ");
		Stack stack = new Stack(strArray.length);
		for(int i = 0;i < strArray.length; i++){
			if(strArray[i].equals("+")){
				num1 = stack.pop();
				num2 = stack.pop();
				stack.push(num1 + num2);
			}
			else if(strArray[i].equals("*")){
				num1 = stack.pop();
				num2 = stack.pop();
				stack.push(num1 * num2);
			}
			else if(strArray[i].equals("-")){
				num1 = stack.pop();
				num2 = stack.pop();
				stack.push(num2 - num1);
			}
			else{
				stack.push(Integer.parseInt(strArray[i]));
			}
		}
		System.out.println(stack.pop());
	} int num1 = 0; num1 0 int num2 = 0; num2 0 BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) String strArray[] = (br.readLine()).split(" "); strArray (br.readLine()).split(" ") (br.readLine()).split (br.readLine()) br.readLine br " " Stack stack = new Stack(strArray.length); stack new Stack(strArray.length) for(int i = 0;i < strArray.length; i++){
			if(strArray[i].equals("+")){
				num1 = stack.pop();
				num2 = stack.pop();
				stack.push(num1 + num2);
			}
			else if(strArray[i].equals("*")){
				num1 = stack.pop();
				num2 = stack.pop();
				stack.push(num1 * num2);
			}
			else if(strArray[i].equals("-")){
				num1 = stack.pop();
				num2 = stack.pop();
				stack.push(num2 - num1);
			}
			else{
				stack.push(Integer.parseInt(strArray[i]));
			}
		} int i = 0; int i = 0; i 0 i < strArray.length i strArray.length strArray strArray.length i++ i++ i {
			if(strArray[i].equals("+")){
				num1 = stack.pop();
				num2 = stack.pop();
				stack.push(num1 + num2);
			}
			else if(strArray[i].equals("*")){
				num1 = stack.pop();
				num2 = stack.pop();
				stack.push(num1 * num2);
			}
			else if(strArray[i].equals("-")){
				num1 = stack.pop();
				num2 = stack.pop();
				stack.push(num2 - num1);
			}
			else{
				stack.push(Integer.parseInt(strArray[i]));
			}
		} {
			if(strArray[i].equals("+")){
				num1 = stack.pop();
				num2 = stack.pop();
				stack.push(num1 + num2);
			}
			else if(strArray[i].equals("*")){
				num1 = stack.pop();
				num2 = stack.pop();
				stack.push(num1 * num2);
			}
			else if(strArray[i].equals("-")){
				num1 = stack.pop();
				num2 = stack.pop();
				stack.push(num2 - num1);
			}
			else{
				stack.push(Integer.parseInt(strArray[i]));
			}
		} if(strArray[i].equals("+")){
				num1 = stack.pop();
				num2 = stack.pop();
				stack.push(num1 + num2);
			}
			else if(strArray[i].equals("*")){
				num1 = stack.pop();
				num2 = stack.pop();
				stack.push(num1 * num2);
			}
			else if(strArray[i].equals("-")){
				num1 = stack.pop();
				num2 = stack.pop();
				stack.push(num2 - num1);
			}
			else{
				stack.push(Integer.parseInt(strArray[i]));
			} strArray[i].equals("+") strArray[i].equals strArray[i] strArray i "+" {
				num1 = stack.pop();
				num2 = stack.pop();
				stack.push(num1 + num2);
			} num1 = stack.pop() num1 stack.pop() stack.pop stack num2 = stack.pop() num2 stack.pop() stack.pop stack stack.push(num1 + num2) stack.push stack num1 + num2 num1 num2 if(strArray[i].equals("*")){
				num1 = stack.pop();
				num2 = stack.pop();
				stack.push(num1 * num2);
			}
			else if(strArray[i].equals("-")){
				num1 = stack.pop();
				num2 = stack.pop();
				stack.push(num2 - num1);
			}
			else{
				stack.push(Integer.parseInt(strArray[i]));
			} strArray[i].equals("*") strArray[i].equals strArray[i] strArray i "*" {
				num1 = stack.pop();
				num2 = stack.pop();
				stack.push(num1 * num2);
			} num1 = stack.pop() num1 stack.pop() stack.pop stack num2 = stack.pop() num2 stack.pop() stack.pop stack stack.push(num1 * num2) stack.push stack num1 * num2 num1 num2 if(strArray[i].equals("-")){
				num1 = stack.pop();
				num2 = stack.pop();
				stack.push(num2 - num1);
			}
			else{
				stack.push(Integer.parseInt(strArray[i]));
			} strArray[i].equals("-") strArray[i].equals strArray[i] strArray i "-" {
				num1 = stack.pop();
				num2 = stack.pop();
				stack.push(num2 - num1);
			} num1 = stack.pop() num1 stack.pop() stack.pop stack num2 = stack.pop() num2 stack.pop() stack.pop stack stack.push(num2 - num1) stack.push stack num2 - num1 num2 num1 {
				stack.push(Integer.parseInt(strArray[i]));
			} stack.push(Integer.parseInt(strArray[i])) stack.push stack Integer.parseInt(strArray[i]) Integer.parseInt Integer strArray[i] strArray i System.out.println(stack.pop()) System.out.println System.out System System.out stack.pop() stack.pop stack String[] args args class Stack{
	private int top;
	private int stack[];

	Stack(int size){
		stack = new int [size];
		top = 0;
	}

	public int pop(){
		return stack[--top];
	}

	public void push(int num){
		stack[top++] = num;
	}
} Stack private int top; top private int stack[]; stack Stack(int size){
		stack = new int [size];
		top = 0;
	} Stack {
		stack = new int [size];
		top = 0;
	} stack = new int [size] stack new int [size] size top = 0 top 0 int size size public int pop(){
		return stack[--top];
	} pop {
		return stack[--top];
	} return stack[--top]; stack[--top] stack --top top public void push(int num){
		stack[top++] = num;
	} push {
		stack[top++] = num;
	} stack[top++] = num stack[top++] stack top++ top num int num num public class Main{

	public static void main(String[] args) throws IOException {
		int num1 = 0;
		int num2 = 0;
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String strArray[] = (br.readLine()).split(" ");
		Stack stack = new Stack(strArray.length);
		for(int i = 0;i < strArray.length; i++){
			if(strArray[i].equals("+")){
				num1 = stack.pop();
				num2 = stack.pop();
				stack.push(num1 + num2);
			}
			else if(strArray[i].equals("*")){
				num1 = stack.pop();
				num2 = stack.pop();
				stack.push(num1 * num2);
			}
			else if(strArray[i].equals("-")){
				num1 = stack.pop();
				num2 = stack.pop();
				stack.push(num2 - num1);
			}
			else{
				stack.push(Integer.parseInt(strArray[i]));
			}
		}
		System.out.println(stack.pop());
	}

} public class Main{

	public static void main(String[] args) throws IOException {
		int num1 = 0;
		int num2 = 0;
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String strArray[] = (br.readLine()).split(" ");
		Stack stack = new Stack(strArray.length);
		for(int i = 0;i < strArray.length; i++){
			if(strArray[i].equals("+")){
				num1 = stack.pop();
				num2 = stack.pop();
				stack.push(num1 + num2);
			}
			else if(strArray[i].equals("*")){
				num1 = stack.pop();
				num2 = stack.pop();
				stack.push(num1 * num2);
			}
			else if(strArray[i].equals("-")){
				num1 = stack.pop();
				num2 = stack.pop();
				stack.push(num2 - num1);
			}
			else{
				stack.push(Integer.parseInt(strArray[i]));
			}
		}
		System.out.println(stack.pop());
	}

} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main{

	public static void main(String[] args) throws IOException {
		int num1 = 0;
		int num2 = 0;
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String strArray[] = (br.readLine()).split(" ");
		Stack stack = new Stack(strArray.length);
		for(int i = 0;i < strArray.length; i++){
			if(strArray[i].equals("+")){
				num1 = stack.pop();
				num2 = stack.pop();
				stack.push(num1 + num2);
			}
			else if(strArray[i].equals("*")){
				num1 = stack.pop();
				num2 = stack.pop();
				stack.push(num1 * num2);
			}
			else if(strArray[i].equals("-")){
				num1 = stack.pop();
				num2 = stack.pop();
				stack.push(num2 - num1);
			}
			else{
				stack.push(Integer.parseInt(strArray[i]));
			}
		}
		System.out.println(stack.pop());
	}

}

class Stack{
	private int top;
	private int stack[];

	Stack(int size){
		stack = new int [size];
		top = 0;
	}

	public int pop(){
		return stack[--top];
	}

	public void push(int num){
		stack[top++] = num;
	}
}