import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        String[] s = sc.nextLine().split(" ");
        Stack stack = new Stack();

        for (int i = 0; i < s.length; i++) {
            if (s[i].equals("+")) {
                int a = stack.pop();
                int b = stack.pop();
                stack.push(a + b);
            } else if (s[i].equals("-")) {
                int a = stack.pop();
                int b = stack.pop();
                stack.push(b - a);
            } else if (s[i].equals("*")) {
                int a = stack.pop();
                int b = stack.pop();
                stack.push(b * a);
            } else {
                int a = Integer.parseInt(s[i]);
                stack.push(a);
            }
        }

        System.out.println(stack.pop());
    }

    static class Stack {
        int[] S;
        int index;

        Stack() {
            S = new int[1000];
            index = 0;
        }

        void push(int x) {
            S[index++] = x;
        }

        int pop() {
            return S[--index];
        }
    }
} import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        String[] s = sc.nextLine().split(" ");
        Stack stack = new Stack();

        for (int i = 0; i < s.length; i++) {
            if (s[i].equals("+")) {
                int a = stack.pop();
                int b = stack.pop();
                stack.push(a + b);
            } else if (s[i].equals("-")) {
                int a = stack.pop();
                int b = stack.pop();
                stack.push(b - a);
            } else if (s[i].equals("*")) {
                int a = stack.pop();
                int b = stack.pop();
                stack.push(b * a);
            } else {
                int a = Integer.parseInt(s[i]);
                stack.push(a);
            }
        }

        System.out.println(stack.pop());
    }

    static class Stack {
        int[] S;
        int index;

        Stack() {
            S = new int[1000];
            index = 0;
        }

        void push(int x) {
            S[index++] = x;
        }

        int pop() {
            return S[--index];
        }
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        String[] s = sc.nextLine().split(" ");
        Stack stack = new Stack();

        for (int i = 0; i < s.length; i++) {
            if (s[i].equals("+")) {
                int a = stack.pop();
                int b = stack.pop();
                stack.push(a + b);
            } else if (s[i].equals("-")) {
                int a = stack.pop();
                int b = stack.pop();
                stack.push(b - a);
            } else if (s[i].equals("*")) {
                int a = stack.pop();
                int b = stack.pop();
                stack.push(b * a);
            } else {
                int a = Integer.parseInt(s[i]);
                stack.push(a);
            }
        }

        System.out.println(stack.pop());
    } main {
        Scanner sc = new Scanner(System.in);

        String[] s = sc.nextLine().split(" ");
        Stack stack = new Stack();

        for (int i = 0; i < s.length; i++) {
            if (s[i].equals("+")) {
                int a = stack.pop();
                int b = stack.pop();
                stack.push(a + b);
            } else if (s[i].equals("-")) {
                int a = stack.pop();
                int b = stack.pop();
                stack.push(b - a);
            } else if (s[i].equals("*")) {
                int a = stack.pop();
                int b = stack.pop();
                stack.push(b * a);
            } else {
                int a = Integer.parseInt(s[i]);
                stack.push(a);
            }
        }

        System.out.println(stack.pop());
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String[] s = sc.nextLine().split(" "); s sc.nextLine().split(" ") sc.nextLine().split sc.nextLine() sc.nextLine sc " " Stack stack = new Stack(); stack new Stack() for (int i = 0; i < s.length; i++) {
            if (s[i].equals("+")) {
                int a = stack.pop();
                int b = stack.pop();
                stack.push(a + b);
            } else if (s[i].equals("-")) {
                int a = stack.pop();
                int b = stack.pop();
                stack.push(b - a);
            } else if (s[i].equals("*")) {
                int a = stack.pop();
                int b = stack.pop();
                stack.push(b * a);
            } else {
                int a = Integer.parseInt(s[i]);
                stack.push(a);
            }
        } int i = 0; int i = 0; i 0 i < s.length i s.length s s.length i++ i++ i {
            if (s[i].equals("+")) {
                int a = stack.pop();
                int b = stack.pop();
                stack.push(a + b);
            } else if (s[i].equals("-")) {
                int a = stack.pop();
                int b = stack.pop();
                stack.push(b - a);
            } else if (s[i].equals("*")) {
                int a = stack.pop();
                int b = stack.pop();
                stack.push(b * a);
            } else {
                int a = Integer.parseInt(s[i]);
                stack.push(a);
            }
        } {
            if (s[i].equals("+")) {
                int a = stack.pop();
                int b = stack.pop();
                stack.push(a + b);
            } else if (s[i].equals("-")) {
                int a = stack.pop();
                int b = stack.pop();
                stack.push(b - a);
            } else if (s[i].equals("*")) {
                int a = stack.pop();
                int b = stack.pop();
                stack.push(b * a);
            } else {
                int a = Integer.parseInt(s[i]);
                stack.push(a);
            }
        } if (s[i].equals("+")) {
                int a = stack.pop();
                int b = stack.pop();
                stack.push(a + b);
            } else if (s[i].equals("-")) {
                int a = stack.pop();
                int b = stack.pop();
                stack.push(b - a);
            } else if (s[i].equals("*")) {
                int a = stack.pop();
                int b = stack.pop();
                stack.push(b * a);
            } else {
                int a = Integer.parseInt(s[i]);
                stack.push(a);
            } s[i].equals("+") s[i].equals s[i] s i "+" {
                int a = stack.pop();
                int b = stack.pop();
                stack.push(a + b);
            } int a = stack.pop(); a stack.pop() stack.pop stack int b = stack.pop(); b stack.pop() stack.pop stack stack.push(a + b) stack.push stack a + b a b if (s[i].equals("-")) {
                int a = stack.pop();
                int b = stack.pop();
                stack.push(b - a);
            } else if (s[i].equals("*")) {
                int a = stack.pop();
                int b = stack.pop();
                stack.push(b * a);
            } else {
                int a = Integer.parseInt(s[i]);
                stack.push(a);
            } s[i].equals("-") s[i].equals s[i] s i "-" {
                int a = stack.pop();
                int b = stack.pop();
                stack.push(b - a);
            } int a = stack.pop(); a stack.pop() stack.pop stack int b = stack.pop(); b stack.pop() stack.pop stack stack.push(b - a) stack.push stack b - a b a if (s[i].equals("*")) {
                int a = stack.pop();
                int b = stack.pop();
                stack.push(b * a);
            } else {
                int a = Integer.parseInt(s[i]);
                stack.push(a);
            } s[i].equals("*") s[i].equals s[i] s i "*" {
                int a = stack.pop();
                int b = stack.pop();
                stack.push(b * a);
            } int a = stack.pop(); a stack.pop() stack.pop stack int b = stack.pop(); b stack.pop() stack.pop stack stack.push(b * a) stack.push stack b * a b a {
                int a = Integer.parseInt(s[i]);
                stack.push(a);
            } int a = Integer.parseInt(s[i]); a Integer.parseInt(s[i]) Integer.parseInt Integer s[i] s i stack.push(a) stack.push stack a System.out.println(stack.pop()) System.out.println System.out System System.out stack.pop() stack.pop stack String[] args args static class Stack {
        int[] S;
        int index;

        Stack() {
            S = new int[1000];
            index = 0;
        }

        void push(int x) {
            S[index++] = x;
        }

        int pop() {
            return S[--index];
        }
    } Stack int[] S; S int index; index Stack() {
            S = new int[1000];
            index = 0;
        } Stack {
            S = new int[1000];
            index = 0;
        } S = new int[1000] S new int[1000] 1000 index = 0 index 0 void push(int x) {
            S[index++] = x;
        } push {
            S[index++] = x;
        } S[index++] = x S[index++] S index++ index x int x x int pop() {
            return S[--index];
        } pop {
            return S[--index];
        } return S[--index]; S[--index] S --index index public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        String[] s = sc.nextLine().split(" ");
        Stack stack = new Stack();

        for (int i = 0; i < s.length; i++) {
            if (s[i].equals("+")) {
                int a = stack.pop();
                int b = stack.pop();
                stack.push(a + b);
            } else if (s[i].equals("-")) {
                int a = stack.pop();
                int b = stack.pop();
                stack.push(b - a);
            } else if (s[i].equals("*")) {
                int a = stack.pop();
                int b = stack.pop();
                stack.push(b * a);
            } else {
                int a = Integer.parseInt(s[i]);
                stack.push(a);
            }
        }

        System.out.println(stack.pop());
    }

    static class Stack {
        int[] S;
        int index;

        Stack() {
            S = new int[1000];
            index = 0;
        }

        void push(int x) {
            S[index++] = x;
        }

        int pop() {
            return S[--index];
        }
    }
} public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        String[] s = sc.nextLine().split(" ");
        Stack stack = new Stack();

        for (int i = 0; i < s.length; i++) {
            if (s[i].equals("+")) {
                int a = stack.pop();
                int b = stack.pop();
                stack.push(a + b);
            } else if (s[i].equals("-")) {
                int a = stack.pop();
                int b = stack.pop();
                stack.push(b - a);
            } else if (s[i].equals("*")) {
                int a = stack.pop();
                int b = stack.pop();
                stack.push(b * a);
            } else {
                int a = Integer.parseInt(s[i]);
                stack.push(a);
            }
        }

        System.out.println(stack.pop());
    }

    static class Stack {
        int[] S;
        int index;

        Stack() {
            S = new int[1000];
            index = 0;
        }

        void push(int x) {
            S[index++] = x;
        }

        int pop() {
            return S[--index];
        }
    }
} Main
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        String[] s = sc.nextLine().split(" ");
        Stack stack = new Stack();

        for (int i = 0; i < s.length; i++) {
            if (s[i].equals("+")) {
                int a = stack.pop();
                int b = stack.pop();
                stack.push(a + b);
            } else if (s[i].equals("-")) {
                int a = stack.pop();
                int b = stack.pop();
                stack.push(b - a);
            } else if (s[i].equals("*")) {
                int a = stack.pop();
                int b = stack.pop();
                stack.push(b * a);
            } else {
                int a = Integer.parseInt(s[i]);
                stack.push(a);
            }
        }

        System.out.println(stack.pop());
    }

    static class Stack {
        int[] S;
        int index;

        Stack() {
            S = new int[1000];
            index = 0;
        }

        void push(int x) {
            S[index++] = x;
        }

        int pop() {
            return S[--index];
        }
    }
}
