import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Stack;
import java.util.StringTokenizer;

class Main{		//スタック練習

	public static void main(String[] args) {

	BufferedReader bfr=new BufferedReader(new InputStreamReader(System.in));
		String str="";
		String toridasi="";
		StringTokenizer stk;
		int stacksize=0;
		Stack<Integer> st=new Stack<Integer>();

		try {
			str=bfr.readLine();
			stk=new StringTokenizer(str," ");
			stacksize=stk.countTokens();
			for(int i=0; i<stacksize; i++) {
				toridasi=stk.nextToken();

				if(toridasi.equals("+") || toridasi.equals("-") || toridasi.equals("*")) {
					int b=st.pop();
					int a=st.pop();
					if(toridasi.equals("+")) {
						st.push(a+b);
					}
					else if(toridasi.equals("-")) {
						st.push(a-b);
					}

					else if(toridasi.equals("*")) {
						st.push(a*b);
					}
				}
				else {
					st.push(Integer.parseInt(toridasi));
				}
			}
			System.out.println(st.pop());
		}
		catch (IOException e) {
			e.printStackTrace();
		}

	}
}
 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.StringTokenizer; StringTokenizer java.util class Main{		//スタック練習

	public static void main(String[] args) {

	BufferedReader bfr=new BufferedReader(new InputStreamReader(System.in));
		String str="";
		String toridasi="";
		StringTokenizer stk;
		int stacksize=0;
		Stack<Integer> st=new Stack<Integer>();

		try {
			str=bfr.readLine();
			stk=new StringTokenizer(str," ");
			stacksize=stk.countTokens();
			for(int i=0; i<stacksize; i++) {
				toridasi=stk.nextToken();

				if(toridasi.equals("+") || toridasi.equals("-") || toridasi.equals("*")) {
					int b=st.pop();
					int a=st.pop();
					if(toridasi.equals("+")) {
						st.push(a+b);
					}
					else if(toridasi.equals("-")) {
						st.push(a-b);
					}

					else if(toridasi.equals("*")) {
						st.push(a*b);
					}
				}
				else {
					st.push(Integer.parseInt(toridasi));
				}
			}
			System.out.println(st.pop());
		}
		catch (IOException e) {
			e.printStackTrace();
		}

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

	BufferedReader bfr=new BufferedReader(new InputStreamReader(System.in));
		String str="";
		String toridasi="";
		StringTokenizer stk;
		int stacksize=0;
		Stack<Integer> st=new Stack<Integer>();

		try {
			str=bfr.readLine();
			stk=new StringTokenizer(str," ");
			stacksize=stk.countTokens();
			for(int i=0; i<stacksize; i++) {
				toridasi=stk.nextToken();

				if(toridasi.equals("+") || toridasi.equals("-") || toridasi.equals("*")) {
					int b=st.pop();
					int a=st.pop();
					if(toridasi.equals("+")) {
						st.push(a+b);
					}
					else if(toridasi.equals("-")) {
						st.push(a-b);
					}

					else if(toridasi.equals("*")) {
						st.push(a*b);
					}
				}
				else {
					st.push(Integer.parseInt(toridasi));
				}
			}
			System.out.println(st.pop());
		}
		catch (IOException e) {
			e.printStackTrace();
		}

	} main {

	BufferedReader bfr=new BufferedReader(new InputStreamReader(System.in));
		String str="";
		String toridasi="";
		StringTokenizer stk;
		int stacksize=0;
		Stack<Integer> st=new Stack<Integer>();

		try {
			str=bfr.readLine();
			stk=new StringTokenizer(str," ");
			stacksize=stk.countTokens();
			for(int i=0; i<stacksize; i++) {
				toridasi=stk.nextToken();

				if(toridasi.equals("+") || toridasi.equals("-") || toridasi.equals("*")) {
					int b=st.pop();
					int a=st.pop();
					if(toridasi.equals("+")) {
						st.push(a+b);
					}
					else if(toridasi.equals("-")) {
						st.push(a-b);
					}

					else if(toridasi.equals("*")) {
						st.push(a*b);
					}
				}
				else {
					st.push(Integer.parseInt(toridasi));
				}
			}
			System.out.println(st.pop());
		}
		catch (IOException e) {
			e.printStackTrace();
		}

	} BufferedReader bfr=new BufferedReader(new InputStreamReader(System.in)); bfr new BufferedReader(new InputStreamReader(System.in)) String str=""; str "" String toridasi=""; toridasi "" StringTokenizer stk; stk int stacksize=0; stacksize 0 Stack<Integer> st=new Stack<Integer>(); st new Stack<Integer>() try {
			str=bfr.readLine();
			stk=new StringTokenizer(str," ");
			stacksize=stk.countTokens();
			for(int i=0; i<stacksize; i++) {
				toridasi=stk.nextToken();

				if(toridasi.equals("+") || toridasi.equals("-") || toridasi.equals("*")) {
					int b=st.pop();
					int a=st.pop();
					if(toridasi.equals("+")) {
						st.push(a+b);
					}
					else if(toridasi.equals("-")) {
						st.push(a-b);
					}

					else if(toridasi.equals("*")) {
						st.push(a*b);
					}
				}
				else {
					st.push(Integer.parseInt(toridasi));
				}
			}
			System.out.println(st.pop());
		}
		catch (IOException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		} IOException e {
			e.printStackTrace();
		} e.printStackTrace() e.printStackTrace e {
			str=bfr.readLine();
			stk=new StringTokenizer(str," ");
			stacksize=stk.countTokens();
			for(int i=0; i<stacksize; i++) {
				toridasi=stk.nextToken();

				if(toridasi.equals("+") || toridasi.equals("-") || toridasi.equals("*")) {
					int b=st.pop();
					int a=st.pop();
					if(toridasi.equals("+")) {
						st.push(a+b);
					}
					else if(toridasi.equals("-")) {
						st.push(a-b);
					}

					else if(toridasi.equals("*")) {
						st.push(a*b);
					}
				}
				else {
					st.push(Integer.parseInt(toridasi));
				}
			}
			System.out.println(st.pop());
		} str=bfr.readLine() str bfr.readLine() bfr.readLine bfr stk=new StringTokenizer(str," ") stk new StringTokenizer(str," ") stacksize=stk.countTokens() stacksize stk.countTokens() stk.countTokens stk for(int i=0; i<stacksize; i++) {
				toridasi=stk.nextToken();

				if(toridasi.equals("+") || toridasi.equals("-") || toridasi.equals("*")) {
					int b=st.pop();
					int a=st.pop();
					if(toridasi.equals("+")) {
						st.push(a+b);
					}
					else if(toridasi.equals("-")) {
						st.push(a-b);
					}

					else if(toridasi.equals("*")) {
						st.push(a*b);
					}
				}
				else {
					st.push(Integer.parseInt(toridasi));
				}
			} int i=0; int i=0; i 0 i<stacksize i stacksize i++ i++ i {
				toridasi=stk.nextToken();

				if(toridasi.equals("+") || toridasi.equals("-") || toridasi.equals("*")) {
					int b=st.pop();
					int a=st.pop();
					if(toridasi.equals("+")) {
						st.push(a+b);
					}
					else if(toridasi.equals("-")) {
						st.push(a-b);
					}

					else if(toridasi.equals("*")) {
						st.push(a*b);
					}
				}
				else {
					st.push(Integer.parseInt(toridasi));
				}
			} {
				toridasi=stk.nextToken();

				if(toridasi.equals("+") || toridasi.equals("-") || toridasi.equals("*")) {
					int b=st.pop();
					int a=st.pop();
					if(toridasi.equals("+")) {
						st.push(a+b);
					}
					else if(toridasi.equals("-")) {
						st.push(a-b);
					}

					else if(toridasi.equals("*")) {
						st.push(a*b);
					}
				}
				else {
					st.push(Integer.parseInt(toridasi));
				}
			} toridasi=stk.nextToken() toridasi stk.nextToken() stk.nextToken stk if(toridasi.equals("+") || toridasi.equals("-") || toridasi.equals("*")) {
					int b=st.pop();
					int a=st.pop();
					if(toridasi.equals("+")) {
						st.push(a+b);
					}
					else if(toridasi.equals("-")) {
						st.push(a-b);
					}

					else if(toridasi.equals("*")) {
						st.push(a*b);
					}
				}
				else {
					st.push(Integer.parseInt(toridasi));
				} toridasi.equals("+") || toridasi.equals("-") || toridasi.equals("*") toridasi.equals("+") || toridasi.equals("-") || toridasi.equals("*") toridasi.equals("+") toridasi.equals toridasi "+" toridasi.equals("-") toridasi.equals toridasi "-" toridasi.equals("*") toridasi.equals toridasi "*" {
					int b=st.pop();
					int a=st.pop();
					if(toridasi.equals("+")) {
						st.push(a+b);
					}
					else if(toridasi.equals("-")) {
						st.push(a-b);
					}

					else if(toridasi.equals("*")) {
						st.push(a*b);
					}
				} int b=st.pop(); b st.pop() st.pop st int a=st.pop(); a st.pop() st.pop st if(toridasi.equals("+")) {
						st.push(a+b);
					}
					else if(toridasi.equals("-")) {
						st.push(a-b);
					}

					else if(toridasi.equals("*")) {
						st.push(a*b);
					} toridasi.equals("+") toridasi.equals toridasi "+" {
						st.push(a+b);
					} st.push(a+b) st.push st a+b a b if(toridasi.equals("-")) {
						st.push(a-b);
					}

					else if(toridasi.equals("*")) {
						st.push(a*b);
					} toridasi.equals("-") toridasi.equals toridasi "-" {
						st.push(a-b);
					} st.push(a-b) st.push st a-b a b if(toridasi.equals("*")) {
						st.push(a*b);
					} toridasi.equals("*") toridasi.equals toridasi "*" {
						st.push(a*b);
					} st.push(a*b) st.push st a*b a b {
					st.push(Integer.parseInt(toridasi));
				} st.push(Integer.parseInt(toridasi)) st.push st Integer.parseInt(toridasi) Integer.parseInt Integer toridasi System.out.println(st.pop()) System.out.println System.out System System.out st.pop() st.pop st String[] args args
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Stack;
import java.util.StringTokenizer;

class Main{		//スタック練習

	public static void main(String[] args) {

	BufferedReader bfr=new BufferedReader(new InputStreamReader(System.in));
		String str="";
		String toridasi="";
		StringTokenizer stk;
		int stacksize=0;
		Stack<Integer> st=new Stack<Integer>();

		try {
			str=bfr.readLine();
			stk=new StringTokenizer(str," ");
			stacksize=stk.countTokens();
			for(int i=0; i<stacksize; i++) {
				toridasi=stk.nextToken();

				if(toridasi.equals("+") || toridasi.equals("-") || toridasi.equals("*")) {
					int b=st.pop();
					int a=st.pop();
					if(toridasi.equals("+")) {
						st.push(a+b);
					}
					else if(toridasi.equals("-")) {
						st.push(a-b);
					}

					else if(toridasi.equals("*")) {
						st.push(a*b);
					}
				}
				else {
					st.push(Integer.parseInt(toridasi));
				}
			}
			System.out.println(st.pop());
		}
		catch (IOException e) {
			e.printStackTrace();
		}

	}
}

