

import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		new Main().start();
	}
	void start(){
		Scanner in = new Scanner(System.in);
		String s = in.nextLine();
		String[] ss = s.split(" ");
		Stack stack = new Stack();
		for(int i = 0; i < ss.length; i++){
			if(ss[i].equals("+")){
				int a = stack.pop();
				int b = stack.pop();
				stack.push(a + b);
			}else if(ss[i].equals("-")){
				int a = stack.pop();
				int b = stack.pop();
				stack.push(b - a);
			}else if(ss[i].equals("*")){
				int a = stack.pop();
				int b = stack.pop();
				stack.push(a * b);
			}else{
				stack.push(Integer.parseInt(ss[i]));
			}
		}
		System.out.println(stack.pop());
		in.close();
	}
}

class Stack {
	int[] data;
	int top = 0;
	Stack(){
		data = new int[101];
		top = 0;
	}
	void push(int x){
		data[top++] = x;
	}
	int pop(){
		return data[--top];
	}
	boolean isEmpty(){
		return top == 0;
	}
	boolean isFull(){
		return top == data.length;
	}
} import java.util.Scanner; Scanner java.util public class Main{
	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		new Main().start();
	}
	void start(){
		Scanner in = new Scanner(System.in);
		String s = in.nextLine();
		String[] ss = s.split(" ");
		Stack stack = new Stack();
		for(int i = 0; i < ss.length; i++){
			if(ss[i].equals("+")){
				int a = stack.pop();
				int b = stack.pop();
				stack.push(a + b);
			}else if(ss[i].equals("-")){
				int a = stack.pop();
				int b = stack.pop();
				stack.push(b - a);
			}else if(ss[i].equals("*")){
				int a = stack.pop();
				int b = stack.pop();
				stack.push(a * b);
			}else{
				stack.push(Integer.parseInt(ss[i]));
			}
		}
		System.out.println(stack.pop());
		in.close();
	}
} Main public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		new Main().start();
	} main {
		// TODO ?????????????????????????????????????????????
		new Main().start();
	} new Main().start() new Main().start new Main() String[] args args void start(){
		Scanner in = new Scanner(System.in);
		String s = in.nextLine();
		String[] ss = s.split(" ");
		Stack stack = new Stack();
		for(int i = 0; i < ss.length; i++){
			if(ss[i].equals("+")){
				int a = stack.pop();
				int b = stack.pop();
				stack.push(a + b);
			}else if(ss[i].equals("-")){
				int a = stack.pop();
				int b = stack.pop();
				stack.push(b - a);
			}else if(ss[i].equals("*")){
				int a = stack.pop();
				int b = stack.pop();
				stack.push(a * b);
			}else{
				stack.push(Integer.parseInt(ss[i]));
			}
		}
		System.out.println(stack.pop());
		in.close();
	} start {
		Scanner in = new Scanner(System.in);
		String s = in.nextLine();
		String[] ss = s.split(" ");
		Stack stack = new Stack();
		for(int i = 0; i < ss.length; i++){
			if(ss[i].equals("+")){
				int a = stack.pop();
				int b = stack.pop();
				stack.push(a + b);
			}else if(ss[i].equals("-")){
				int a = stack.pop();
				int b = stack.pop();
				stack.push(b - a);
			}else if(ss[i].equals("*")){
				int a = stack.pop();
				int b = stack.pop();
				stack.push(a * b);
			}else{
				stack.push(Integer.parseInt(ss[i]));
			}
		}
		System.out.println(stack.pop());
		in.close();
	} Scanner in = new Scanner(System.in); in new Scanner(System.in) String s = in.nextLine(); s in.nextLine() in.nextLine in String[] ss = s.split(" "); ss s.split(" ") s.split s " " Stack stack = new Stack(); stack new Stack() for(int i = 0; i < ss.length; i++){
			if(ss[i].equals("+")){
				int a = stack.pop();
				int b = stack.pop();
				stack.push(a + b);
			}else if(ss[i].equals("-")){
				int a = stack.pop();
				int b = stack.pop();
				stack.push(b - a);
			}else if(ss[i].equals("*")){
				int a = stack.pop();
				int b = stack.pop();
				stack.push(a * b);
			}else{
				stack.push(Integer.parseInt(ss[i]));
			}
		} int i = 0; int i = 0; i 0 i < ss.length i ss.length ss ss.length i++ i++ i {
			if(ss[i].equals("+")){
				int a = stack.pop();
				int b = stack.pop();
				stack.push(a + b);
			}else if(ss[i].equals("-")){
				int a = stack.pop();
				int b = stack.pop();
				stack.push(b - a);
			}else if(ss[i].equals("*")){
				int a = stack.pop();
				int b = stack.pop();
				stack.push(a * b);
			}else{
				stack.push(Integer.parseInt(ss[i]));
			}
		} {
			if(ss[i].equals("+")){
				int a = stack.pop();
				int b = stack.pop();
				stack.push(a + b);
			}else if(ss[i].equals("-")){
				int a = stack.pop();
				int b = stack.pop();
				stack.push(b - a);
			}else if(ss[i].equals("*")){
				int a = stack.pop();
				int b = stack.pop();
				stack.push(a * b);
			}else{
				stack.push(Integer.parseInt(ss[i]));
			}
		} if(ss[i].equals("+")){
				int a = stack.pop();
				int b = stack.pop();
				stack.push(a + b);
			}else if(ss[i].equals("-")){
				int a = stack.pop();
				int b = stack.pop();
				stack.push(b - a);
			}else if(ss[i].equals("*")){
				int a = stack.pop();
				int b = stack.pop();
				stack.push(a * b);
			}else{
				stack.push(Integer.parseInt(ss[i]));
			} ss[i].equals("+") ss[i].equals ss[i] ss i "+" {
				int a = stack.pop();
				int b = stack.pop();
				stack.push(a + b);
			} int a = stack.pop(); a stack.pop() stack.pop stack int b = stack.pop(); b stack.pop() stack.pop stack stack.push(a + b) stack.push stack a + b a b if(ss[i].equals("-")){
				int a = stack.pop();
				int b = stack.pop();
				stack.push(b - a);
			}else if(ss[i].equals("*")){
				int a = stack.pop();
				int b = stack.pop();
				stack.push(a * b);
			}else{
				stack.push(Integer.parseInt(ss[i]));
			} ss[i].equals("-") ss[i].equals ss[i] ss i "-" {
				int a = stack.pop();
				int b = stack.pop();
				stack.push(b - a);
			} int a = stack.pop(); a stack.pop() stack.pop stack int b = stack.pop(); b stack.pop() stack.pop stack stack.push(b - a) stack.push stack b - a b a if(ss[i].equals("*")){
				int a = stack.pop();
				int b = stack.pop();
				stack.push(a * b);
			}else{
				stack.push(Integer.parseInt(ss[i]));
			} ss[i].equals("*") ss[i].equals ss[i] ss i "*" {
				int a = stack.pop();
				int b = stack.pop();
				stack.push(a * b);
			} int a = stack.pop(); a stack.pop() stack.pop stack int b = stack.pop(); b stack.pop() stack.pop stack stack.push(a * b) stack.push stack a * b a b {
				stack.push(Integer.parseInt(ss[i]));
			} stack.push(Integer.parseInt(ss[i])) stack.push stack Integer.parseInt(ss[i]) Integer.parseInt Integer ss[i] ss i System.out.println(stack.pop()) System.out.println System.out System System.out stack.pop() stack.pop stack in.close() in.close in class Stack {
	int[] data;
	int top = 0;
	Stack(){
		data = new int[101];
		top = 0;
	}
	void push(int x){
		data[top++] = x;
	}
	int pop(){
		return data[--top];
	}
	boolean isEmpty(){
		return top == 0;
	}
	boolean isFull(){
		return top == data.length;
	}
} Stack int[] data; data int top = 0; top 0 Stack(){
		data = new int[101];
		top = 0;
	} Stack {
		data = new int[101];
		top = 0;
	} data = new int[101] data new int[101] 101 top = 0 top 0 void push(int x){
		data[top++] = x;
	} push {
		data[top++] = x;
	} data[top++] = x data[top++] data top++ top x int x x int pop(){
		return data[--top];
	} pop {
		return data[--top];
	} return data[--top]; data[--top] data --top top boolean isEmpty(){
		return top == 0;
	} isEmpty {
		return top == 0;
	} return top == 0; top == 0 top 0 boolean isFull(){
		return top == data.length;
	} isFull {
		return top == data.length;
	} return top == data.length; top == data.length top data.length data data.length public class Main{
	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		new Main().start();
	}
	void start(){
		Scanner in = new Scanner(System.in);
		String s = in.nextLine();
		String[] ss = s.split(" ");
		Stack stack = new Stack();
		for(int i = 0; i < ss.length; i++){
			if(ss[i].equals("+")){
				int a = stack.pop();
				int b = stack.pop();
				stack.push(a + b);
			}else if(ss[i].equals("-")){
				int a = stack.pop();
				int b = stack.pop();
				stack.push(b - a);
			}else if(ss[i].equals("*")){
				int a = stack.pop();
				int b = stack.pop();
				stack.push(a * b);
			}else{
				stack.push(Integer.parseInt(ss[i]));
			}
		}
		System.out.println(stack.pop());
		in.close();
	}
} public class Main{
	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		new Main().start();
	}
	void start(){
		Scanner in = new Scanner(System.in);
		String s = in.nextLine();
		String[] ss = s.split(" ");
		Stack stack = new Stack();
		for(int i = 0; i < ss.length; i++){
			if(ss[i].equals("+")){
				int a = stack.pop();
				int b = stack.pop();
				stack.push(a + b);
			}else if(ss[i].equals("-")){
				int a = stack.pop();
				int b = stack.pop();
				stack.push(b - a);
			}else if(ss[i].equals("*")){
				int a = stack.pop();
				int b = stack.pop();
				stack.push(a * b);
			}else{
				stack.push(Integer.parseInt(ss[i]));
			}
		}
		System.out.println(stack.pop());
		in.close();
	}
} Main


import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		new Main().start();
	}
	void start(){
		Scanner in = new Scanner(System.in);
		String s = in.nextLine();
		String[] ss = s.split(" ");
		Stack stack = new Stack();
		for(int i = 0; i < ss.length; i++){
			if(ss[i].equals("+")){
				int a = stack.pop();
				int b = stack.pop();
				stack.push(a + b);
			}else if(ss[i].equals("-")){
				int a = stack.pop();
				int b = stack.pop();
				stack.push(b - a);
			}else if(ss[i].equals("*")){
				int a = stack.pop();
				int b = stack.pop();
				stack.push(a * b);
			}else{
				stack.push(Integer.parseInt(ss[i]));
			}
		}
		System.out.println(stack.pop());
		in.close();
	}
}

class Stack {
	int[] data;
	int top = 0;
	Stack(){
		data = new int[101];
		top = 0;
	}
	void push(int x){
		data[top++] = x;
	}
	int pop(){
		return data[--top];
	}
	boolean isEmpty(){
		return top == 0;
	}
	boolean isFull(){
		return top == data.length;
	}
}