import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Stack;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main {

	public static final int BIG_NUM  = 2000000000;
	public static final int MOD  = 1000000007;

	public static void main(String[] args) {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		Stack<Integer> S = new Stack<Integer>();
		int A,B;

		try {

			String input[] = br.readLine().split("\\s+");

			for(int i = 0; i < input.length; i++){
				if(checkInt(input[i])){
					S.push(Integer.parseInt(input[i]));
					continue;
				}

				B = S.peek();
				S.pop();
				A = S.peek();
				S.pop();

				if(input[i].equals("+")){
					S.push(A+B);
				}else if(input[i].equals("*")){
					S.push(A*B);
				}else if(input[i].equals("-")){
					S.push(A-B);
				}
			}
			System.out.println(S.peek());

		} catch (NumberFormatException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	public static boolean checkInt(String number){
		Pattern p = Pattern.compile("^[0-9]+$");
		Matcher m = p.matcher(number);
		return m.matches();
	}

}
 import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io import java.util.Stack; Stack java.util import java.util.regex.Matcher; Matcher java.util.regex import java.util.regex.Pattern; Pattern java.util.regex public class Main {

	public static final int BIG_NUM  = 2000000000;
	public static final int MOD  = 1000000007;

	public static void main(String[] args) {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		Stack<Integer> S = new Stack<Integer>();
		int A,B;

		try {

			String input[] = br.readLine().split("\\s+");

			for(int i = 0; i < input.length; i++){
				if(checkInt(input[i])){
					S.push(Integer.parseInt(input[i]));
					continue;
				}

				B = S.peek();
				S.pop();
				A = S.peek();
				S.pop();

				if(input[i].equals("+")){
					S.push(A+B);
				}else if(input[i].equals("*")){
					S.push(A*B);
				}else if(input[i].equals("-")){
					S.push(A-B);
				}
			}
			System.out.println(S.peek());

		} catch (NumberFormatException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	public static boolean checkInt(String number){
		Pattern p = Pattern.compile("^[0-9]+$");
		Matcher m = p.matcher(number);
		return m.matches();
	}

} Main public static final int BIG_NUM  = 2000000000; BIG_NUM 2000000000 public static final int MOD  = 1000000007; MOD 1000000007 public static void main(String[] args) {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		Stack<Integer> S = new Stack<Integer>();
		int A,B;

		try {

			String input[] = br.readLine().split("\\s+");

			for(int i = 0; i < input.length; i++){
				if(checkInt(input[i])){
					S.push(Integer.parseInt(input[i]));
					continue;
				}

				B = S.peek();
				S.pop();
				A = S.peek();
				S.pop();

				if(input[i].equals("+")){
					S.push(A+B);
				}else if(input[i].equals("*")){
					S.push(A*B);
				}else if(input[i].equals("-")){
					S.push(A-B);
				}
			}
			System.out.println(S.peek());

		} catch (NumberFormatException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
	} main {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		Stack<Integer> S = new Stack<Integer>();
		int A,B;

		try {

			String input[] = br.readLine().split("\\s+");

			for(int i = 0; i < input.length; i++){
				if(checkInt(input[i])){
					S.push(Integer.parseInt(input[i]));
					continue;
				}

				B = S.peek();
				S.pop();
				A = S.peek();
				S.pop();

				if(input[i].equals("+")){
					S.push(A+B);
				}else if(input[i].equals("*")){
					S.push(A*B);
				}else if(input[i].equals("-")){
					S.push(A-B);
				}
			}
			System.out.println(S.peek());

		} catch (NumberFormatException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
	} BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) Stack<Integer> S = new Stack<Integer>(); S new Stack<Integer>() int A A B; B try {

			String input[] = br.readLine().split("\\s+");

			for(int i = 0; i < input.length; i++){
				if(checkInt(input[i])){
					S.push(Integer.parseInt(input[i]));
					continue;
				}

				B = S.peek();
				S.pop();
				A = S.peek();
				S.pop();

				if(input[i].equals("+")){
					S.push(A+B);
				}else if(input[i].equals("*")){
					S.push(A*B);
				}else if(input[i].equals("-")){
					S.push(A-B);
				}
			}
			System.out.println(S.peek());

		} catch (NumberFormatException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		} catch (NumberFormatException e) {
			e.printStackTrace();
		} NumberFormatException e {
			e.printStackTrace();
		} e.printStackTrace() e.printStackTrace e catch (IOException e) {
			e.printStackTrace();
		} IOException e {
			e.printStackTrace();
		} e.printStackTrace() e.printStackTrace e {

			String input[] = br.readLine().split("\\s+");

			for(int i = 0; i < input.length; i++){
				if(checkInt(input[i])){
					S.push(Integer.parseInt(input[i]));
					continue;
				}

				B = S.peek();
				S.pop();
				A = S.peek();
				S.pop();

				if(input[i].equals("+")){
					S.push(A+B);
				}else if(input[i].equals("*")){
					S.push(A*B);
				}else if(input[i].equals("-")){
					S.push(A-B);
				}
			}
			System.out.println(S.peek());

		} String input[] = br.readLine().split("\\s+"); input br.readLine().split("\\s+") br.readLine().split br.readLine() br.readLine br "\\s+" for(int i = 0; i < input.length; i++){
				if(checkInt(input[i])){
					S.push(Integer.parseInt(input[i]));
					continue;
				}

				B = S.peek();
				S.pop();
				A = S.peek();
				S.pop();

				if(input[i].equals("+")){
					S.push(A+B);
				}else if(input[i].equals("*")){
					S.push(A*B);
				}else if(input[i].equals("-")){
					S.push(A-B);
				}
			} int i = 0; int i = 0; i 0 i < input.length i input.length input input.length i++ i++ i {
				if(checkInt(input[i])){
					S.push(Integer.parseInt(input[i]));
					continue;
				}

				B = S.peek();
				S.pop();
				A = S.peek();
				S.pop();

				if(input[i].equals("+")){
					S.push(A+B);
				}else if(input[i].equals("*")){
					S.push(A*B);
				}else if(input[i].equals("-")){
					S.push(A-B);
				}
			} {
				if(checkInt(input[i])){
					S.push(Integer.parseInt(input[i]));
					continue;
				}

				B = S.peek();
				S.pop();
				A = S.peek();
				S.pop();

				if(input[i].equals("+")){
					S.push(A+B);
				}else if(input[i].equals("*")){
					S.push(A*B);
				}else if(input[i].equals("-")){
					S.push(A-B);
				}
			} if(checkInt(input[i])){
					S.push(Integer.parseInt(input[i]));
					continue;
				} checkInt(input[i]) checkInt input[i] input i {
					S.push(Integer.parseInt(input[i]));
					continue;
				} S.push(Integer.parseInt(input[i])) S.push S Integer.parseInt(input[i]) Integer.parseInt Integer input[i] input i continue; B = S.peek() B S.peek() S.peek S S.pop() S.pop S A = S.peek() A S.peek() S.peek S S.pop() S.pop S if(input[i].equals("+")){
					S.push(A+B);
				}else if(input[i].equals("*")){
					S.push(A*B);
				}else if(input[i].equals("-")){
					S.push(A-B);
				} input[i].equals("+") input[i].equals input[i] input i "+" {
					S.push(A+B);
				} S.push(A+B) S.push S A+B A B if(input[i].equals("*")){
					S.push(A*B);
				}else if(input[i].equals("-")){
					S.push(A-B);
				} input[i].equals("*") input[i].equals input[i] input i "*" {
					S.push(A*B);
				} S.push(A*B) S.push S A*B A B if(input[i].equals("-")){
					S.push(A-B);
				} input[i].equals("-") input[i].equals input[i] input i "-" {
					S.push(A-B);
				} S.push(A-B) S.push S A-B A B System.out.println(S.peek()) System.out.println System.out System System.out S.peek() S.peek S String[] args args public static boolean checkInt(String number){
		Pattern p = Pattern.compile("^[0-9]+$");
		Matcher m = p.matcher(number);
		return m.matches();
	} checkInt {
		Pattern p = Pattern.compile("^[0-9]+$");
		Matcher m = p.matcher(number);
		return m.matches();
	} Pattern p = Pattern.compile("^[0-9]+$"); p Pattern.compile("^[0-9]+$") Pattern.compile Pattern "^[0-9]+$" Matcher m = p.matcher(number); m p.matcher(number) p.matcher p number return m.matches(); m.matches() m.matches m String number number public class Main {

	public static final int BIG_NUM  = 2000000000;
	public static final int MOD  = 1000000007;

	public static void main(String[] args) {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		Stack<Integer> S = new Stack<Integer>();
		int A,B;

		try {

			String input[] = br.readLine().split("\\s+");

			for(int i = 0; i < input.length; i++){
				if(checkInt(input[i])){
					S.push(Integer.parseInt(input[i]));
					continue;
				}

				B = S.peek();
				S.pop();
				A = S.peek();
				S.pop();

				if(input[i].equals("+")){
					S.push(A+B);
				}else if(input[i].equals("*")){
					S.push(A*B);
				}else if(input[i].equals("-")){
					S.push(A-B);
				}
			}
			System.out.println(S.peek());

		} catch (NumberFormatException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	public static boolean checkInt(String number){
		Pattern p = Pattern.compile("^[0-9]+$");
		Matcher m = p.matcher(number);
		return m.matches();
	}

} public class Main {

	public static final int BIG_NUM  = 2000000000;
	public static final int MOD  = 1000000007;

	public static void main(String[] args) {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		Stack<Integer> S = new Stack<Integer>();
		int A,B;

		try {

			String input[] = br.readLine().split("\\s+");

			for(int i = 0; i < input.length; i++){
				if(checkInt(input[i])){
					S.push(Integer.parseInt(input[i]));
					continue;
				}

				B = S.peek();
				S.pop();
				A = S.peek();
				S.pop();

				if(input[i].equals("+")){
					S.push(A+B);
				}else if(input[i].equals("*")){
					S.push(A*B);
				}else if(input[i].equals("-")){
					S.push(A-B);
				}
			}
			System.out.println(S.peek());

		} catch (NumberFormatException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	public static boolean checkInt(String number){
		Pattern p = Pattern.compile("^[0-9]+$");
		Matcher m = p.matcher(number);
		return m.matches();
	}

} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Stack;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main {

	public static final int BIG_NUM  = 2000000000;
	public static final int MOD  = 1000000007;

	public static void main(String[] args) {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		Stack<Integer> S = new Stack<Integer>();
		int A,B;

		try {

			String input[] = br.readLine().split("\\s+");

			for(int i = 0; i < input.length; i++){
				if(checkInt(input[i])){
					S.push(Integer.parseInt(input[i]));
					continue;
				}

				B = S.peek();
				S.pop();
				A = S.peek();
				S.pop();

				if(input[i].equals("+")){
					S.push(A+B);
				}else if(input[i].equals("*")){
					S.push(A*B);
				}else if(input[i].equals("-")){
					S.push(A-B);
				}
			}
			System.out.println(S.peek());

		} catch (NumberFormatException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	public static boolean checkInt(String number){
		Pattern p = Pattern.compile("^[0-9]+$");
		Matcher m = p.matcher(number);
		return m.matches();
	}

}

