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

class Main{

	public static void main(String[] args) throws IOException{

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] input = br.readLine().split(" ");
		Stack s = new Stack();

		for(int i = 0; i < input.length; i++){

			int x = 0;
			int y = 0;

			switch(input[i]){

				case "+":
					y = s.pop();
					x = s.pop();
					s.push(x + y);
					break;
				case "-":
					y = s.pop();
					x = s.pop();
					s.push(x - y);
					break;
				case "*":
					y = s.pop();
					x = s.pop();
					s.push(x * y);
					break;
				default:
					s.push(Integer.parseInt(input[i]));

			}

		}

		System.out.println(s.pop());

	}

}

class Stack{

	public static int size = 0;
	private int[] array;

	public Stack(){

		array = new int[100];

	}

	public void push(int n){

		array[size] = n;
		size++;

	}

	public int pop(){

		size--;

		return array[size];

	}

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

	public static void main(String[] args) throws IOException{

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] input = br.readLine().split(" ");
		Stack s = new Stack();

		for(int i = 0; i < input.length; i++){

			int x = 0;
			int y = 0;

			switch(input[i]){

				case "+":
					y = s.pop();
					x = s.pop();
					s.push(x + y);
					break;
				case "-":
					y = s.pop();
					x = s.pop();
					s.push(x - y);
					break;
				case "*":
					y = s.pop();
					x = s.pop();
					s.push(x * y);
					break;
				default:
					s.push(Integer.parseInt(input[i]));

			}

		}

		System.out.println(s.pop());

	}

} Main public static void main(String[] args) throws IOException{

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] input = br.readLine().split(" ");
		Stack s = new Stack();

		for(int i = 0; i < input.length; i++){

			int x = 0;
			int y = 0;

			switch(input[i]){

				case "+":
					y = s.pop();
					x = s.pop();
					s.push(x + y);
					break;
				case "-":
					y = s.pop();
					x = s.pop();
					s.push(x - y);
					break;
				case "*":
					y = s.pop();
					x = s.pop();
					s.push(x * y);
					break;
				default:
					s.push(Integer.parseInt(input[i]));

			}

		}

		System.out.println(s.pop());

	} main {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] input = br.readLine().split(" ");
		Stack s = new Stack();

		for(int i = 0; i < input.length; i++){

			int x = 0;
			int y = 0;

			switch(input[i]){

				case "+":
					y = s.pop();
					x = s.pop();
					s.push(x + y);
					break;
				case "-":
					y = s.pop();
					x = s.pop();
					s.push(x - y);
					break;
				case "*":
					y = s.pop();
					x = s.pop();
					s.push(x * y);
					break;
				default:
					s.push(Integer.parseInt(input[i]));

			}

		}

		System.out.println(s.pop());

	} BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) String[] input = br.readLine().split(" "); input br.readLine().split(" ") br.readLine().split br.readLine() br.readLine br " " Stack s = new Stack(); s new Stack() for(int i = 0; i < input.length; i++){

			int x = 0;
			int y = 0;

			switch(input[i]){

				case "+":
					y = s.pop();
					x = s.pop();
					s.push(x + y);
					break;
				case "-":
					y = s.pop();
					x = s.pop();
					s.push(x - y);
					break;
				case "*":
					y = s.pop();
					x = s.pop();
					s.push(x * y);
					break;
				default:
					s.push(Integer.parseInt(input[i]));

			}

		} int i = 0; int i = 0; i 0 i < input.length i input.length input input.length i++ i++ i {

			int x = 0;
			int y = 0;

			switch(input[i]){

				case "+":
					y = s.pop();
					x = s.pop();
					s.push(x + y);
					break;
				case "-":
					y = s.pop();
					x = s.pop();
					s.push(x - y);
					break;
				case "*":
					y = s.pop();
					x = s.pop();
					s.push(x * y);
					break;
				default:
					s.push(Integer.parseInt(input[i]));

			}

		} {

			int x = 0;
			int y = 0;

			switch(input[i]){

				case "+":
					y = s.pop();
					x = s.pop();
					s.push(x + y);
					break;
				case "-":
					y = s.pop();
					x = s.pop();
					s.push(x - y);
					break;
				case "*":
					y = s.pop();
					x = s.pop();
					s.push(x * y);
					break;
				default:
					s.push(Integer.parseInt(input[i]));

			}

		} int x = 0; x 0 int y = 0; y 0 switch(input[i]){

				case "+":
					y = s.pop();
					x = s.pop();
					s.push(x + y);
					break;
				case "-":
					y = s.pop();
					x = s.pop();
					s.push(x - y);
					break;
				case "*":
					y = s.pop();
					x = s.pop();
					s.push(x * y);
					break;
				default:
					s.push(Integer.parseInt(input[i]));

			} input[i] input i case "+": "+" case "+": y = s.pop() y s.pop() s.pop s x = s.pop() x s.pop() s.pop s s.push(x + y) s.push s x + y x y break; case "-": "-" case "-": y = s.pop() y s.pop() s.pop s x = s.pop() x s.pop() s.pop s s.push(x - y) s.push s x - y x y break; case "*": "*" case "*": y = s.pop() y s.pop() s.pop s x = s.pop() x s.pop() s.pop s s.push(x * y) s.push s x * y x y break; default: default: s.push(Integer.parseInt(input[i])) s.push s Integer.parseInt(input[i]) Integer.parseInt Integer input[i] input i System.out.println(s.pop()) System.out.println System.out System System.out s.pop() s.pop s String[] args args class Stack{

	public static int size = 0;
	private int[] array;

	public Stack(){

		array = new int[100];

	}

	public void push(int n){

		array[size] = n;
		size++;

	}

	public int pop(){

		size--;

		return array[size];

	}

} Stack public static int size = 0; size 0 private int[] array; array public Stack(){

		array = new int[100];

	} Stack {

		array = new int[100];

	} array = new int[100] array new int[100] 100 public void push(int n){

		array[size] = n;
		size++;

	} push {

		array[size] = n;
		size++;

	} array[size] = n array[size] array size n size++ size int n n public int pop(){

		size--;

		return array[size];

	} pop {

		size--;

		return array[size];

	} size-- size return array[size]; array[size] array size
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

class Main{

	public static void main(String[] args) throws IOException{

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] input = br.readLine().split(" ");
		Stack s = new Stack();

		for(int i = 0; i < input.length; i++){

			int x = 0;
			int y = 0;

			switch(input[i]){

				case "+":
					y = s.pop();
					x = s.pop();
					s.push(x + y);
					break;
				case "-":
					y = s.pop();
					x = s.pop();
					s.push(x - y);
					break;
				case "*":
					y = s.pop();
					x = s.pop();
					s.push(x * y);
					break;
				default:
					s.push(Integer.parseInt(input[i]));

			}

		}

		System.out.println(s.pop());

	}

}

class Stack{

	public static int size = 0;
	private int[] array;

	public Stack(){

		array = new int[100];

	}

	public void push(int n){

		array[size] = n;
		size++;

	}

	public int pop(){

		size--;

		return array[size];

	}

}