import java.io.*;
import java.util.*;

public class Main {
    // 要素数　最後の位置
    public static int top = 0;
    public static int[] stack = new int[200];

    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        ArrayDeque<Integer> st = new ArrayDeque<>();
        String[] inputStr = sc.nextLine().split(" ");


        // stack を　使うやり方
        for(String str : inputStr){
            if(str.equals("+")){
                int a = st.pop();
                int b = st.pop();
                st.push(a + b);
            }else if(str.equals("-")){
                int a = st.pop();
                int b = st.pop();
                st.push(b - a);
            }else if(str.equals("*")){
                int a = st.pop();
                int b = st.pop();
                st.push(a * b);
            }else{
                st.push(Integer.parseInt(str));
            }
        }
        System.out.println(st.pop());


        // stackを再現するやり方

        /*
        for(String str : inputStr){
            if(str.equals("+")){
                int a = pop();
                int b = pop();
                push(a + b);
            }else if(str.equals("-")){
                int a = pop();
                int b = pop();
                push(b - a);
            }else if(str.equals("*")){
                int a = pop();
                int b = pop();
                push(a * b);
            }else{
                push(Integer.parseInt(str));
            }
        }
        System.out.println(pop());
        
         */



    }
    public static void push(int x){
        top++;
        stack[top] = x;
    }
    public static int pop(){
        top--;
        return stack[top+1];
    }


    static class FastScanner {
        private BufferedReader reader = null;
        private StringTokenizer tokenizer = null;

        public FastScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
            tokenizer = null;
        }

        public String next() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public String nextLine() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    return reader.readLine();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }

            return tokenizer.nextToken("\n");
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public long nextInt() {
            return Integer.parseInt(next());
        }

    }
} import java.io.*; io.* java import java.util.*; util.* java public class Main {
    // 要素数　最後の位置
    public static int top = 0;
    public static int[] stack = new int[200];

    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        ArrayDeque<Integer> st = new ArrayDeque<>();
        String[] inputStr = sc.nextLine().split(" ");


        // stack を　使うやり方
        for(String str : inputStr){
            if(str.equals("+")){
                int a = st.pop();
                int b = st.pop();
                st.push(a + b);
            }else if(str.equals("-")){
                int a = st.pop();
                int b = st.pop();
                st.push(b - a);
            }else if(str.equals("*")){
                int a = st.pop();
                int b = st.pop();
                st.push(a * b);
            }else{
                st.push(Integer.parseInt(str));
            }
        }
        System.out.println(st.pop());


        // stackを再現するやり方

        /*
        for(String str : inputStr){
            if(str.equals("+")){
                int a = pop();
                int b = pop();
                push(a + b);
            }else if(str.equals("-")){
                int a = pop();
                int b = pop();
                push(b - a);
            }else if(str.equals("*")){
                int a = pop();
                int b = pop();
                push(a * b);
            }else{
                push(Integer.parseInt(str));
            }
        }
        System.out.println(pop());
        
         */



    }
    public static void push(int x){
        top++;
        stack[top] = x;
    }
    public static int pop(){
        top--;
        return stack[top+1];
    }


    static class FastScanner {
        private BufferedReader reader = null;
        private StringTokenizer tokenizer = null;

        public FastScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
            tokenizer = null;
        }

        public String next() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public String nextLine() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    return reader.readLine();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }

            return tokenizer.nextToken("\n");
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public long nextInt() {
            return Integer.parseInt(next());
        }

    }
} Main // 要素数　最後の位置
    public static int top = 0; top 0 public static int[] stack = new int[200]; stack new int[200] 200 public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        ArrayDeque<Integer> st = new ArrayDeque<>();
        String[] inputStr = sc.nextLine().split(" ");


        // stack を　使うやり方
        for(String str : inputStr){
            if(str.equals("+")){
                int a = st.pop();
                int b = st.pop();
                st.push(a + b);
            }else if(str.equals("-")){
                int a = st.pop();
                int b = st.pop();
                st.push(b - a);
            }else if(str.equals("*")){
                int a = st.pop();
                int b = st.pop();
                st.push(a * b);
            }else{
                st.push(Integer.parseInt(str));
            }
        }
        System.out.println(st.pop());


        // stackを再現するやり方

        /*
        for(String str : inputStr){
            if(str.equals("+")){
                int a = pop();
                int b = pop();
                push(a + b);
            }else if(str.equals("-")){
                int a = pop();
                int b = pop();
                push(b - a);
            }else if(str.equals("*")){
                int a = pop();
                int b = pop();
                push(a * b);
            }else{
                push(Integer.parseInt(str));
            }
        }
        System.out.println(pop());
        
         */



    } main {
        FastScanner sc = new FastScanner(System.in);
        ArrayDeque<Integer> st = new ArrayDeque<>();
        String[] inputStr = sc.nextLine().split(" ");


        // stack を　使うやり方
        for(String str : inputStr){
            if(str.equals("+")){
                int a = st.pop();
                int b = st.pop();
                st.push(a + b);
            }else if(str.equals("-")){
                int a = st.pop();
                int b = st.pop();
                st.push(b - a);
            }else if(str.equals("*")){
                int a = st.pop();
                int b = st.pop();
                st.push(a * b);
            }else{
                st.push(Integer.parseInt(str));
            }
        }
        System.out.println(st.pop());


        // stackを再現するやり方

        /*
        for(String str : inputStr){
            if(str.equals("+")){
                int a = pop();
                int b = pop();
                push(a + b);
            }else if(str.equals("-")){
                int a = pop();
                int b = pop();
                push(b - a);
            }else if(str.equals("*")){
                int a = pop();
                int b = pop();
                push(a * b);
            }else{
                push(Integer.parseInt(str));
            }
        }
        System.out.println(pop());
        
         */



    } FastScanner sc = new FastScanner(System.in); sc new FastScanner(System.in) ArrayDeque<Integer> st = new ArrayDeque<>(); st new ArrayDeque<>() String[] inputStr = sc.nextLine().split(" "); inputStr sc.nextLine().split(" ") sc.nextLine().split sc.nextLine() sc.nextLine sc " " for(String str : inputStr){
            if(str.equals("+")){
                int a = st.pop();
                int b = st.pop();
                st.push(a + b);
            }else if(str.equals("-")){
                int a = st.pop();
                int b = st.pop();
                st.push(b - a);
            }else if(str.equals("*")){
                int a = st.pop();
                int b = st.pop();
                st.push(a * b);
            }else{
                st.push(Integer.parseInt(str));
            }
        } String str inputStr {
            if(str.equals("+")){
                int a = st.pop();
                int b = st.pop();
                st.push(a + b);
            }else if(str.equals("-")){
                int a = st.pop();
                int b = st.pop();
                st.push(b - a);
            }else if(str.equals("*")){
                int a = st.pop();
                int b = st.pop();
                st.push(a * b);
            }else{
                st.push(Integer.parseInt(str));
            }
        } {
            if(str.equals("+")){
                int a = st.pop();
                int b = st.pop();
                st.push(a + b);
            }else if(str.equals("-")){
                int a = st.pop();
                int b = st.pop();
                st.push(b - a);
            }else if(str.equals("*")){
                int a = st.pop();
                int b = st.pop();
                st.push(a * b);
            }else{
                st.push(Integer.parseInt(str));
            }
        } if(str.equals("+")){
                int a = st.pop();
                int b = st.pop();
                st.push(a + b);
            }else if(str.equals("-")){
                int a = st.pop();
                int b = st.pop();
                st.push(b - a);
            }else if(str.equals("*")){
                int a = st.pop();
                int b = st.pop();
                st.push(a * b);
            }else{
                st.push(Integer.parseInt(str));
            } str.equals("+") str.equals str "+" {
                int a = st.pop();
                int b = st.pop();
                st.push(a + b);
            } int a = st.pop(); a st.pop() st.pop st int b = st.pop(); b st.pop() st.pop st st.push(a + b) st.push st a + b a b if(str.equals("-")){
                int a = st.pop();
                int b = st.pop();
                st.push(b - a);
            }else if(str.equals("*")){
                int a = st.pop();
                int b = st.pop();
                st.push(a * b);
            }else{
                st.push(Integer.parseInt(str));
            } str.equals("-") str.equals str "-" {
                int a = st.pop();
                int b = st.pop();
                st.push(b - a);
            } int a = st.pop(); a st.pop() st.pop st int b = st.pop(); b st.pop() st.pop st st.push(b - a) st.push st b - a b a if(str.equals("*")){
                int a = st.pop();
                int b = st.pop();
                st.push(a * b);
            }else{
                st.push(Integer.parseInt(str));
            } str.equals("*") str.equals str "*" {
                int a = st.pop();
                int b = st.pop();
                st.push(a * b);
            } int a = st.pop(); a st.pop() st.pop st int b = st.pop(); b st.pop() st.pop st st.push(a * b) st.push st a * b a b {
                st.push(Integer.parseInt(str));
            } st.push(Integer.parseInt(str)) st.push st Integer.parseInt(str) Integer.parseInt Integer str System.out.println(st.pop()) System.out.println System.out System System.out st.pop() st.pop st String[] args args public static void push(int x){
        top++;
        stack[top] = x;
    } push {
        top++;
        stack[top] = x;
    } top++ top stack[top] = x stack[top] stack top x int x x public static int pop(){
        top--;
        return stack[top+1];
    } pop {
        top--;
        return stack[top+1];
    } top-- top return stack[top+1]; stack[top+1] stack top+1 top 1 static class FastScanner {
        private BufferedReader reader = null;
        private StringTokenizer tokenizer = null;

        public FastScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
            tokenizer = null;
        }

        public String next() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public String nextLine() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    return reader.readLine();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }

            return tokenizer.nextToken("\n");
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public long nextInt() {
            return Integer.parseInt(next());
        }

    } FastScanner private BufferedReader reader = null; reader null private StringTokenizer tokenizer = null; tokenizer null public FastScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
            tokenizer = null;
        } FastScanner {
            reader = new BufferedReader(new InputStreamReader(in));
            tokenizer = null;
        } reader = new BufferedReader(new InputStreamReader(in)) reader new BufferedReader(new InputStreamReader(in)) tokenizer = null tokenizer null InputStream in in public String next() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        } next {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        } if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            } tokenizer == null || !tokenizer.hasMoreTokens() tokenizer == null tokenizer null !tokenizer.hasMoreTokens() tokenizer.hasMoreTokens() tokenizer.hasMoreTokens tokenizer {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            } try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                } catch (IOException e) {
                    throw new RuntimeException(e);
                } IOException e {
                    throw new RuntimeException(e);
                } throw new RuntimeException(e); new RuntimeException(e) {
                    tokenizer = new StringTokenizer(reader.readLine());
                } tokenizer = new StringTokenizer(reader.readLine()) tokenizer new StringTokenizer(reader.readLine()) return tokenizer.nextToken(); tokenizer.nextToken() tokenizer.nextToken tokenizer public String nextLine() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    return reader.readLine();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }

            return tokenizer.nextToken("\n");
        } nextLine {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    return reader.readLine();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }

            return tokenizer.nextToken("\n");
        } if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    return reader.readLine();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            } tokenizer == null || !tokenizer.hasMoreTokens() tokenizer == null tokenizer null !tokenizer.hasMoreTokens() tokenizer.hasMoreTokens() tokenizer.hasMoreTokens tokenizer {
                try {
                    return reader.readLine();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            } try {
                    return reader.readLine();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                } catch (IOException e) {
                    throw new RuntimeException(e);
                } IOException e {
                    throw new RuntimeException(e);
                } throw new RuntimeException(e); new RuntimeException(e) {
                    return reader.readLine();
                } return reader.readLine(); reader.readLine() reader.readLine reader return tokenizer.nextToken("\n"); tokenizer.nextToken("\n") tokenizer.nextToken tokenizer "\n" public long nextLong() {
            return Long.parseLong(next());
        } nextLong {
            return Long.parseLong(next());
        } return Long.parseLong(next()); Long.parseLong(next()) Long.parseLong Long next() next public long nextInt() {
            return Integer.parseInt(next());
        } nextInt {
            return Integer.parseInt(next());
        } return Integer.parseInt(next()); Integer.parseInt(next()) Integer.parseInt Integer next() next public class Main {
    // 要素数　最後の位置
    public static int top = 0;
    public static int[] stack = new int[200];

    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        ArrayDeque<Integer> st = new ArrayDeque<>();
        String[] inputStr = sc.nextLine().split(" ");


        // stack を　使うやり方
        for(String str : inputStr){
            if(str.equals("+")){
                int a = st.pop();
                int b = st.pop();
                st.push(a + b);
            }else if(str.equals("-")){
                int a = st.pop();
                int b = st.pop();
                st.push(b - a);
            }else if(str.equals("*")){
                int a = st.pop();
                int b = st.pop();
                st.push(a * b);
            }else{
                st.push(Integer.parseInt(str));
            }
        }
        System.out.println(st.pop());


        // stackを再現するやり方

        /*
        for(String str : inputStr){
            if(str.equals("+")){
                int a = pop();
                int b = pop();
                push(a + b);
            }else if(str.equals("-")){
                int a = pop();
                int b = pop();
                push(b - a);
            }else if(str.equals("*")){
                int a = pop();
                int b = pop();
                push(a * b);
            }else{
                push(Integer.parseInt(str));
            }
        }
        System.out.println(pop());
        
         */



    }
    public static void push(int x){
        top++;
        stack[top] = x;
    }
    public static int pop(){
        top--;
        return stack[top+1];
    }


    static class FastScanner {
        private BufferedReader reader = null;
        private StringTokenizer tokenizer = null;

        public FastScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
            tokenizer = null;
        }

        public String next() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public String nextLine() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    return reader.readLine();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }

            return tokenizer.nextToken("\n");
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public long nextInt() {
            return Integer.parseInt(next());
        }

    }
} public class Main {
    // 要素数　最後の位置
    public static int top = 0;
    public static int[] stack = new int[200];

    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        ArrayDeque<Integer> st = new ArrayDeque<>();
        String[] inputStr = sc.nextLine().split(" ");


        // stack を　使うやり方
        for(String str : inputStr){
            if(str.equals("+")){
                int a = st.pop();
                int b = st.pop();
                st.push(a + b);
            }else if(str.equals("-")){
                int a = st.pop();
                int b = st.pop();
                st.push(b - a);
            }else if(str.equals("*")){
                int a = st.pop();
                int b = st.pop();
                st.push(a * b);
            }else{
                st.push(Integer.parseInt(str));
            }
        }
        System.out.println(st.pop());


        // stackを再現するやり方

        /*
        for(String str : inputStr){
            if(str.equals("+")){
                int a = pop();
                int b = pop();
                push(a + b);
            }else if(str.equals("-")){
                int a = pop();
                int b = pop();
                push(b - a);
            }else if(str.equals("*")){
                int a = pop();
                int b = pop();
                push(a * b);
            }else{
                push(Integer.parseInt(str));
            }
        }
        System.out.println(pop());
        
         */



    }
    public static void push(int x){
        top++;
        stack[top] = x;
    }
    public static int pop(){
        top--;
        return stack[top+1];
    }


    static class FastScanner {
        private BufferedReader reader = null;
        private StringTokenizer tokenizer = null;

        public FastScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
            tokenizer = null;
        }

        public String next() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public String nextLine() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    return reader.readLine();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }

            return tokenizer.nextToken("\n");
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public long nextInt() {
            return Integer.parseInt(next());
        }

    }
} Main
import java.io.*;
import java.util.*;

public class Main {
    // 要素数　最後の位置
    public static int top = 0;
    public static int[] stack = new int[200];

    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        ArrayDeque<Integer> st = new ArrayDeque<>();
        String[] inputStr = sc.nextLine().split(" ");


        // stack を　使うやり方
        for(String str : inputStr){
            if(str.equals("+")){
                int a = st.pop();
                int b = st.pop();
                st.push(a + b);
            }else if(str.equals("-")){
                int a = st.pop();
                int b = st.pop();
                st.push(b - a);
            }else if(str.equals("*")){
                int a = st.pop();
                int b = st.pop();
                st.push(a * b);
            }else{
                st.push(Integer.parseInt(str));
            }
        }
        System.out.println(st.pop());


        // stackを再現するやり方

        /*
        for(String str : inputStr){
            if(str.equals("+")){
                int a = pop();
                int b = pop();
                push(a + b);
            }else if(str.equals("-")){
                int a = pop();
                int b = pop();
                push(b - a);
            }else if(str.equals("*")){
                int a = pop();
                int b = pop();
                push(a * b);
            }else{
                push(Integer.parseInt(str));
            }
        }
        System.out.println(pop());
        
         */



    }
    public static void push(int x){
        top++;
        stack[top] = x;
    }
    public static int pop(){
        top--;
        return stack[top+1];
    }


    static class FastScanner {
        private BufferedReader reader = null;
        private StringTokenizer tokenizer = null;

        public FastScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
            tokenizer = null;
        }

        public String next() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public String nextLine() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    return reader.readLine();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }

            return tokenizer.nextToken("\n");
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public long nextInt() {
            return Integer.parseInt(next());
        }

    }
}
