import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.Deque;

class Main{
    public static void main(String[] args) throws IOException{
        final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        final Deque<Integer> st = new ArrayDeque<Integer>(128);
        final String[] in = br.readLine().split(" ");
        for(int i = 0; i<in.length; i++){
            if(in[i].equals("+")){
                final int b = st.poll();
                final int a = st.poll();
                st.addFirst(a+b);
            }else if(in[i].equals("-")){
                final int b = st.poll();
                final int a = st.poll();
                st.addFirst(a-b);
            }else if(in[i].equals("*")){
                final int b = st.poll();
                final int a = st.poll();
                st.addFirst(a*b);
            }else{
                st.addFirst(Integer.valueOf(in[i]));
            }
        }
        System.out.println(st.peek());
    }
} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io import java.util.ArrayDeque; ArrayDeque java.util import java.util.Deque; Deque java.util class Main{
    public static void main(String[] args) throws IOException{
        final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        final Deque<Integer> st = new ArrayDeque<Integer>(128);
        final String[] in = br.readLine().split(" ");
        for(int i = 0; i<in.length; i++){
            if(in[i].equals("+")){
                final int b = st.poll();
                final int a = st.poll();
                st.addFirst(a+b);
            }else if(in[i].equals("-")){
                final int b = st.poll();
                final int a = st.poll();
                st.addFirst(a-b);
            }else if(in[i].equals("*")){
                final int b = st.poll();
                final int a = st.poll();
                st.addFirst(a*b);
            }else{
                st.addFirst(Integer.valueOf(in[i]));
            }
        }
        System.out.println(st.peek());
    }
} Main public static void main(String[] args) throws IOException{
        final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        final Deque<Integer> st = new ArrayDeque<Integer>(128);
        final String[] in = br.readLine().split(" ");
        for(int i = 0; i<in.length; i++){
            if(in[i].equals("+")){
                final int b = st.poll();
                final int a = st.poll();
                st.addFirst(a+b);
            }else if(in[i].equals("-")){
                final int b = st.poll();
                final int a = st.poll();
                st.addFirst(a-b);
            }else if(in[i].equals("*")){
                final int b = st.poll();
                final int a = st.poll();
                st.addFirst(a*b);
            }else{
                st.addFirst(Integer.valueOf(in[i]));
            }
        }
        System.out.println(st.peek());
    } main {
        final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        final Deque<Integer> st = new ArrayDeque<Integer>(128);
        final String[] in = br.readLine().split(" ");
        for(int i = 0; i<in.length; i++){
            if(in[i].equals("+")){
                final int b = st.poll();
                final int a = st.poll();
                st.addFirst(a+b);
            }else if(in[i].equals("-")){
                final int b = st.poll();
                final int a = st.poll();
                st.addFirst(a-b);
            }else if(in[i].equals("*")){
                final int b = st.poll();
                final int a = st.poll();
                st.addFirst(a*b);
            }else{
                st.addFirst(Integer.valueOf(in[i]));
            }
        }
        System.out.println(st.peek());
    } final BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) final Deque<Integer> st = new ArrayDeque<Integer>(128); st new ArrayDeque<Integer>(128) final String[] in = br.readLine().split(" "); in br.readLine().split(" ") br.readLine().split br.readLine() br.readLine br " " for(int i = 0; i<in.length; i++){
            if(in[i].equals("+")){
                final int b = st.poll();
                final int a = st.poll();
                st.addFirst(a+b);
            }else if(in[i].equals("-")){
                final int b = st.poll();
                final int a = st.poll();
                st.addFirst(a-b);
            }else if(in[i].equals("*")){
                final int b = st.poll();
                final int a = st.poll();
                st.addFirst(a*b);
            }else{
                st.addFirst(Integer.valueOf(in[i]));
            }
        } int i = 0; int i = 0; i 0 i<in.length i in.length in in.length i++ i++ i {
            if(in[i].equals("+")){
                final int b = st.poll();
                final int a = st.poll();
                st.addFirst(a+b);
            }else if(in[i].equals("-")){
                final int b = st.poll();
                final int a = st.poll();
                st.addFirst(a-b);
            }else if(in[i].equals("*")){
                final int b = st.poll();
                final int a = st.poll();
                st.addFirst(a*b);
            }else{
                st.addFirst(Integer.valueOf(in[i]));
            }
        } {
            if(in[i].equals("+")){
                final int b = st.poll();
                final int a = st.poll();
                st.addFirst(a+b);
            }else if(in[i].equals("-")){
                final int b = st.poll();
                final int a = st.poll();
                st.addFirst(a-b);
            }else if(in[i].equals("*")){
                final int b = st.poll();
                final int a = st.poll();
                st.addFirst(a*b);
            }else{
                st.addFirst(Integer.valueOf(in[i]));
            }
        } if(in[i].equals("+")){
                final int b = st.poll();
                final int a = st.poll();
                st.addFirst(a+b);
            }else if(in[i].equals("-")){
                final int b = st.poll();
                final int a = st.poll();
                st.addFirst(a-b);
            }else if(in[i].equals("*")){
                final int b = st.poll();
                final int a = st.poll();
                st.addFirst(a*b);
            }else{
                st.addFirst(Integer.valueOf(in[i]));
            } in[i].equals("+") in[i].equals in[i] in i "+" {
                final int b = st.poll();
                final int a = st.poll();
                st.addFirst(a+b);
            } final int b = st.poll(); b st.poll() st.poll st final int a = st.poll(); a st.poll() st.poll st st.addFirst(a+b) st.addFirst st a+b a b if(in[i].equals("-")){
                final int b = st.poll();
                final int a = st.poll();
                st.addFirst(a-b);
            }else if(in[i].equals("*")){
                final int b = st.poll();
                final int a = st.poll();
                st.addFirst(a*b);
            }else{
                st.addFirst(Integer.valueOf(in[i]));
            } in[i].equals("-") in[i].equals in[i] in i "-" {
                final int b = st.poll();
                final int a = st.poll();
                st.addFirst(a-b);
            } final int b = st.poll(); b st.poll() st.poll st final int a = st.poll(); a st.poll() st.poll st st.addFirst(a-b) st.addFirst st a-b a b if(in[i].equals("*")){
                final int b = st.poll();
                final int a = st.poll();
                st.addFirst(a*b);
            }else{
                st.addFirst(Integer.valueOf(in[i]));
            } in[i].equals("*") in[i].equals in[i] in i "*" {
                final int b = st.poll();
                final int a = st.poll();
                st.addFirst(a*b);
            } final int b = st.poll(); b st.poll() st.poll st final int a = st.poll(); a st.poll() st.poll st st.addFirst(a*b) st.addFirst st a*b a b {
                st.addFirst(Integer.valueOf(in[i]));
            } st.addFirst(Integer.valueOf(in[i])) st.addFirst st Integer.valueOf(in[i]) Integer.valueOf Integer in[i] in i System.out.println(st.peek()) System.out.println System.out System System.out st.peek() st.peek st String[] args args
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.Deque;

class Main{
    public static void main(String[] args) throws IOException{
        final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        final Deque<Integer> st = new ArrayDeque<Integer>(128);
        final String[] in = br.readLine().split(" ");
        for(int i = 0; i<in.length; i++){
            if(in[i].equals("+")){
                final int b = st.poll();
                final int a = st.poll();
                st.addFirst(a+b);
            }else if(in[i].equals("-")){
                final int b = st.poll();
                final int a = st.poll();
                st.addFirst(a-b);
            }else if(in[i].equals("*")){
                final int b = st.poll();
                final int a = st.poll();
                st.addFirst(a*b);
            }else{
                st.addFirst(Integer.valueOf(in[i]));
            }
        }
        System.out.println(st.peek());
    }
}