import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        AizuRPN solver = new AizuRPN();
        solver.solve(1, in, out);
        out.close();
    }

    static class AizuRPN {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            final String s = in.nextLine().trim();

            AizuRPN.Stack st = new AizuRPN.Stack(1000);
            String[] input = s.split(" ");

            for (String x : input) {
                if (x.equals("+")) {
                    long b = Long.parseLong(st.pop());
                    long a = Long.parseLong(st.pop());

                    st.push(String.valueOf(a + b));
                } else if (x.equals("-")) {
                    long b = Long.parseLong(st.pop());
                    long a = Long.parseLong(st.pop());

                    st.push(String.valueOf(a - b));
                } else if (x.equals("*")) {
                    long b = Long.parseLong(st.pop());
                    long a = Long.parseLong(st.pop());

                    st.push(String.valueOf(a * b));
                } else {
                    st.push(x);
                }
            }

            out.printf("%s\n", st.pop());
        }

        static class Stack {
            private String[] a;
            private int top;

            public Stack(final int n) {
                a = new String[n];
                top = -1;
            }

            public boolean isEmpty() {
                return top == -1;
            }

            public void push(String c) {
                a[++top] = c;
            }

            public String pop() {
                if (isEmpty()) {
                    throw new IllegalStateException("empty stack");
                }

                return a[top--];
            }

        }

    }
}

 import java.io.OutputStream; OutputStream java.io import java.io.IOException; IOException java.io import java.io.InputStream; InputStream java.io import java.io.PrintWriter; PrintWriter java.io import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        AizuRPN solver = new AizuRPN();
        solver.solve(1, in, out);
        out.close();
    }

    static class AizuRPN {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            final String s = in.nextLine().trim();

            AizuRPN.Stack st = new AizuRPN.Stack(1000);
            String[] input = s.split(" ");

            for (String x : input) {
                if (x.equals("+")) {
                    long b = Long.parseLong(st.pop());
                    long a = Long.parseLong(st.pop());

                    st.push(String.valueOf(a + b));
                } else if (x.equals("-")) {
                    long b = Long.parseLong(st.pop());
                    long a = Long.parseLong(st.pop());

                    st.push(String.valueOf(a - b));
                } else if (x.equals("*")) {
                    long b = Long.parseLong(st.pop());
                    long a = Long.parseLong(st.pop());

                    st.push(String.valueOf(a * b));
                } else {
                    st.push(x);
                }
            }

            out.printf("%s\n", st.pop());
        }

        static class Stack {
            private String[] a;
            private int top;

            public Stack(final int n) {
                a = new String[n];
                top = -1;
            }

            public boolean isEmpty() {
                return top == -1;
            }

            public void push(String c) {
                a[++top] = c;
            }

            public String pop() {
                if (isEmpty()) {
                    throw new IllegalStateException("empty stack");
                }

                return a[top--];
            }

        }

    }
} Main public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        AizuRPN solver = new AizuRPN();
        solver.solve(1, in, out);
        out.close();
    } main {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        AizuRPN solver = new AizuRPN();
        solver.solve(1, in, out);
        out.close();
    } InputStream inputStream = System.in; inputStream System.in System System.in OutputStream outputStream = System.out; outputStream System.out System System.out Scanner in = new Scanner(inputStream); in new Scanner(inputStream) PrintWriter out = new PrintWriter(outputStream); out new PrintWriter(outputStream) AizuRPN solver = new AizuRPN(); solver new AizuRPN() solver.solve(1, in, out) solver.solve solver 1 in out out.close() out.close out String[] args args static class AizuRPN {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            final String s = in.nextLine().trim();

            AizuRPN.Stack st = new AizuRPN.Stack(1000);
            String[] input = s.split(" ");

            for (String x : input) {
                if (x.equals("+")) {
                    long b = Long.parseLong(st.pop());
                    long a = Long.parseLong(st.pop());

                    st.push(String.valueOf(a + b));
                } else if (x.equals("-")) {
                    long b = Long.parseLong(st.pop());
                    long a = Long.parseLong(st.pop());

                    st.push(String.valueOf(a - b));
                } else if (x.equals("*")) {
                    long b = Long.parseLong(st.pop());
                    long a = Long.parseLong(st.pop());

                    st.push(String.valueOf(a * b));
                } else {
                    st.push(x);
                }
            }

            out.printf("%s\n", st.pop());
        }

        static class Stack {
            private String[] a;
            private int top;

            public Stack(final int n) {
                a = new String[n];
                top = -1;
            }

            public boolean isEmpty() {
                return top == -1;
            }

            public void push(String c) {
                a[++top] = c;
            }

            public String pop() {
                if (isEmpty()) {
                    throw new IllegalStateException("empty stack");
                }

                return a[top--];
            }

        }

    } AizuRPN public void solve(int testNumber, Scanner in, PrintWriter out) {
            final String s = in.nextLine().trim();

            AizuRPN.Stack st = new AizuRPN.Stack(1000);
            String[] input = s.split(" ");

            for (String x : input) {
                if (x.equals("+")) {
                    long b = Long.parseLong(st.pop());
                    long a = Long.parseLong(st.pop());

                    st.push(String.valueOf(a + b));
                } else if (x.equals("-")) {
                    long b = Long.parseLong(st.pop());
                    long a = Long.parseLong(st.pop());

                    st.push(String.valueOf(a - b));
                } else if (x.equals("*")) {
                    long b = Long.parseLong(st.pop());
                    long a = Long.parseLong(st.pop());

                    st.push(String.valueOf(a * b));
                } else {
                    st.push(x);
                }
            }

            out.printf("%s\n", st.pop());
        } solve {
            final String s = in.nextLine().trim();

            AizuRPN.Stack st = new AizuRPN.Stack(1000);
            String[] input = s.split(" ");

            for (String x : input) {
                if (x.equals("+")) {
                    long b = Long.parseLong(st.pop());
                    long a = Long.parseLong(st.pop());

                    st.push(String.valueOf(a + b));
                } else if (x.equals("-")) {
                    long b = Long.parseLong(st.pop());
                    long a = Long.parseLong(st.pop());

                    st.push(String.valueOf(a - b));
                } else if (x.equals("*")) {
                    long b = Long.parseLong(st.pop());
                    long a = Long.parseLong(st.pop());

                    st.push(String.valueOf(a * b));
                } else {
                    st.push(x);
                }
            }

            out.printf("%s\n", st.pop());
        } final String s = in.nextLine().trim(); s in.nextLine().trim() in.nextLine().trim in.nextLine() in.nextLine in AizuRPN.Stack st = new AizuRPN.Stack(1000); st new AizuRPN.Stack(1000) String[] input = s.split(" "); input s.split(" ") s.split s " " for (String x : input) {
                if (x.equals("+")) {
                    long b = Long.parseLong(st.pop());
                    long a = Long.parseLong(st.pop());

                    st.push(String.valueOf(a + b));
                } else if (x.equals("-")) {
                    long b = Long.parseLong(st.pop());
                    long a = Long.parseLong(st.pop());

                    st.push(String.valueOf(a - b));
                } else if (x.equals("*")) {
                    long b = Long.parseLong(st.pop());
                    long a = Long.parseLong(st.pop());

                    st.push(String.valueOf(a * b));
                } else {
                    st.push(x);
                }
            } String x input {
                if (x.equals("+")) {
                    long b = Long.parseLong(st.pop());
                    long a = Long.parseLong(st.pop());

                    st.push(String.valueOf(a + b));
                } else if (x.equals("-")) {
                    long b = Long.parseLong(st.pop());
                    long a = Long.parseLong(st.pop());

                    st.push(String.valueOf(a - b));
                } else if (x.equals("*")) {
                    long b = Long.parseLong(st.pop());
                    long a = Long.parseLong(st.pop());

                    st.push(String.valueOf(a * b));
                } else {
                    st.push(x);
                }
            } {
                if (x.equals("+")) {
                    long b = Long.parseLong(st.pop());
                    long a = Long.parseLong(st.pop());

                    st.push(String.valueOf(a + b));
                } else if (x.equals("-")) {
                    long b = Long.parseLong(st.pop());
                    long a = Long.parseLong(st.pop());

                    st.push(String.valueOf(a - b));
                } else if (x.equals("*")) {
                    long b = Long.parseLong(st.pop());
                    long a = Long.parseLong(st.pop());

                    st.push(String.valueOf(a * b));
                } else {
                    st.push(x);
                }
            } if (x.equals("+")) {
                    long b = Long.parseLong(st.pop());
                    long a = Long.parseLong(st.pop());

                    st.push(String.valueOf(a + b));
                } else if (x.equals("-")) {
                    long b = Long.parseLong(st.pop());
                    long a = Long.parseLong(st.pop());

                    st.push(String.valueOf(a - b));
                } else if (x.equals("*")) {
                    long b = Long.parseLong(st.pop());
                    long a = Long.parseLong(st.pop());

                    st.push(String.valueOf(a * b));
                } else {
                    st.push(x);
                } x.equals("+") x.equals x "+" {
                    long b = Long.parseLong(st.pop());
                    long a = Long.parseLong(st.pop());

                    st.push(String.valueOf(a + b));
                } long b = Long.parseLong(st.pop()); b Long.parseLong(st.pop()) Long.parseLong Long st.pop() st.pop st long a = Long.parseLong(st.pop()); a Long.parseLong(st.pop()) Long.parseLong Long st.pop() st.pop st st.push(String.valueOf(a + b)) st.push st String.valueOf(a + b) String.valueOf String a + b a b if (x.equals("-")) {
                    long b = Long.parseLong(st.pop());
                    long a = Long.parseLong(st.pop());

                    st.push(String.valueOf(a - b));
                } else if (x.equals("*")) {
                    long b = Long.parseLong(st.pop());
                    long a = Long.parseLong(st.pop());

                    st.push(String.valueOf(a * b));
                } else {
                    st.push(x);
                } x.equals("-") x.equals x "-" {
                    long b = Long.parseLong(st.pop());
                    long a = Long.parseLong(st.pop());

                    st.push(String.valueOf(a - b));
                } long b = Long.parseLong(st.pop()); b Long.parseLong(st.pop()) Long.parseLong Long st.pop() st.pop st long a = Long.parseLong(st.pop()); a Long.parseLong(st.pop()) Long.parseLong Long st.pop() st.pop st st.push(String.valueOf(a - b)) st.push st String.valueOf(a - b) String.valueOf String a - b a b if (x.equals("*")) {
                    long b = Long.parseLong(st.pop());
                    long a = Long.parseLong(st.pop());

                    st.push(String.valueOf(a * b));
                } else {
                    st.push(x);
                } x.equals("*") x.equals x "*" {
                    long b = Long.parseLong(st.pop());
                    long a = Long.parseLong(st.pop());

                    st.push(String.valueOf(a * b));
                } long b = Long.parseLong(st.pop()); b Long.parseLong(st.pop()) Long.parseLong Long st.pop() st.pop st long a = Long.parseLong(st.pop()); a Long.parseLong(st.pop()) Long.parseLong Long st.pop() st.pop st st.push(String.valueOf(a * b)) st.push st String.valueOf(a * b) String.valueOf String a * b a b {
                    st.push(x);
                } st.push(x) st.push st x out.printf("%s\n", st.pop()) out.printf out "%s\n" st.pop() st.pop st int testNumber testNumber Scanner in in PrintWriter out out static class Stack {
            private String[] a;
            private int top;

            public Stack(final int n) {
                a = new String[n];
                top = -1;
            }

            public boolean isEmpty() {
                return top == -1;
            }

            public void push(String c) {
                a[++top] = c;
            }

            public String pop() {
                if (isEmpty()) {
                    throw new IllegalStateException("empty stack");
                }

                return a[top--];
            }

        } Stack private String[] a; a private int top; top public Stack(final int n) {
                a = new String[n];
                top = -1;
            } Stack {
                a = new String[n];
                top = -1;
            } a = new String[n] a new String[n] n top = -1 top -1 1 final int n n public boolean isEmpty() {
                return top == -1;
            } isEmpty {
                return top == -1;
            } return top == -1; top == -1 top -1 1 public void push(String c) {
                a[++top] = c;
            } push {
                a[++top] = c;
            } a[++top] = c a[++top] a ++top top c String c c public String pop() {
                if (isEmpty()) {
                    throw new IllegalStateException("empty stack");
                }

                return a[top--];
            } pop {
                if (isEmpty()) {
                    throw new IllegalStateException("empty stack");
                }

                return a[top--];
            } if (isEmpty()) {
                    throw new IllegalStateException("empty stack");
                } isEmpty() isEmpty {
                    throw new IllegalStateException("empty stack");
                } throw new IllegalStateException("empty stack"); new IllegalStateException("empty stack") return a[top--]; a[top--] a top-- top public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        AizuRPN solver = new AizuRPN();
        solver.solve(1, in, out);
        out.close();
    }

    static class AizuRPN {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            final String s = in.nextLine().trim();

            AizuRPN.Stack st = new AizuRPN.Stack(1000);
            String[] input = s.split(" ");

            for (String x : input) {
                if (x.equals("+")) {
                    long b = Long.parseLong(st.pop());
                    long a = Long.parseLong(st.pop());

                    st.push(String.valueOf(a + b));
                } else if (x.equals("-")) {
                    long b = Long.parseLong(st.pop());
                    long a = Long.parseLong(st.pop());

                    st.push(String.valueOf(a - b));
                } else if (x.equals("*")) {
                    long b = Long.parseLong(st.pop());
                    long a = Long.parseLong(st.pop());

                    st.push(String.valueOf(a * b));
                } else {
                    st.push(x);
                }
            }

            out.printf("%s\n", st.pop());
        }

        static class Stack {
            private String[] a;
            private int top;

            public Stack(final int n) {
                a = new String[n];
                top = -1;
            }

            public boolean isEmpty() {
                return top == -1;
            }

            public void push(String c) {
                a[++top] = c;
            }

            public String pop() {
                if (isEmpty()) {
                    throw new IllegalStateException("empty stack");
                }

                return a[top--];
            }

        }

    }
} public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        AizuRPN solver = new AizuRPN();
        solver.solve(1, in, out);
        out.close();
    }

    static class AizuRPN {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            final String s = in.nextLine().trim();

            AizuRPN.Stack st = new AizuRPN.Stack(1000);
            String[] input = s.split(" ");

            for (String x : input) {
                if (x.equals("+")) {
                    long b = Long.parseLong(st.pop());
                    long a = Long.parseLong(st.pop());

                    st.push(String.valueOf(a + b));
                } else if (x.equals("-")) {
                    long b = Long.parseLong(st.pop());
                    long a = Long.parseLong(st.pop());

                    st.push(String.valueOf(a - b));
                } else if (x.equals("*")) {
                    long b = Long.parseLong(st.pop());
                    long a = Long.parseLong(st.pop());

                    st.push(String.valueOf(a * b));
                } else {
                    st.push(x);
                }
            }

            out.printf("%s\n", st.pop());
        }

        static class Stack {
            private String[] a;
            private int top;

            public Stack(final int n) {
                a = new String[n];
                top = -1;
            }

            public boolean isEmpty() {
                return top == -1;
            }

            public void push(String c) {
                a[++top] = c;
            }

            public String pop() {
                if (isEmpty()) {
                    throw new IllegalStateException("empty stack");
                }

                return a[top--];
            }

        }

    }
} Main
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        AizuRPN solver = new AizuRPN();
        solver.solve(1, in, out);
        out.close();
    }

    static class AizuRPN {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            final String s = in.nextLine().trim();

            AizuRPN.Stack st = new AizuRPN.Stack(1000);
            String[] input = s.split(" ");

            for (String x : input) {
                if (x.equals("+")) {
                    long b = Long.parseLong(st.pop());
                    long a = Long.parseLong(st.pop());

                    st.push(String.valueOf(a + b));
                } else if (x.equals("-")) {
                    long b = Long.parseLong(st.pop());
                    long a = Long.parseLong(st.pop());

                    st.push(String.valueOf(a - b));
                } else if (x.equals("*")) {
                    long b = Long.parseLong(st.pop());
                    long a = Long.parseLong(st.pop());

                    st.push(String.valueOf(a * b));
                } else {
                    st.push(x);
                }
            }

            out.printf("%s\n", st.pop());
        }

        static class Stack {
            private String[] a;
            private int top;

            public Stack(final int n) {
                a = new String[n];
                top = -1;
            }

            public boolean isEmpty() {
                return top == -1;
            }

            public void push(String c) {
                a[++top] = c;
            }

            public String pop() {
                if (isEmpty()) {
                    throw new IllegalStateException("empty stack");
                }

                return a[top--];
            }

        }

    }
}


