import java.util.*;

public class Main {

    static int top;
    static int[] s;

    static void push(int x) {
        s[++top] = x;
    }

    static int pop() {
        top--;
        return s[top + 1];
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        s = new int[1000];
        while (sc.hasNext()) {
            String s = sc.next();
            char c = s.charAt(0);
            if (c == '+') {
                int k = pop();
                int k2 = pop();
                push(k2 + k);
            } else if (c == '-') {
                int k = pop();
                int k2 = pop();
                push(k2 - k);
            } else if (c == '*') {
                int k = pop();
                int k2 = pop();
                push(k2 * k);
            } else {
                push(Integer.parseInt(s));
            }

        }
        System.out.println(pop());
        sc.close();
    }
} import java.util.*; util.* java public class Main {

    static int top;
    static int[] s;

    static void push(int x) {
        s[++top] = x;
    }

    static int pop() {
        top--;
        return s[top + 1];
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        s = new int[1000];
        while (sc.hasNext()) {
            String s = sc.next();
            char c = s.charAt(0);
            if (c == '+') {
                int k = pop();
                int k2 = pop();
                push(k2 + k);
            } else if (c == '-') {
                int k = pop();
                int k2 = pop();
                push(k2 - k);
            } else if (c == '*') {
                int k = pop();
                int k2 = pop();
                push(k2 * k);
            } else {
                push(Integer.parseInt(s));
            }

        }
        System.out.println(pop());
        sc.close();
    }
} Main static int top; top static int[] s; s static void push(int x) {
        s[++top] = x;
    } push {
        s[++top] = x;
    } s[++top] = x s[++top] s ++top top x int x x static int pop() {
        top--;
        return s[top + 1];
    } pop {
        top--;
        return s[top + 1];
    } top-- top return s[top + 1]; s[top + 1] s top + 1 top 1 public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        s = new int[1000];
        while (sc.hasNext()) {
            String s = sc.next();
            char c = s.charAt(0);
            if (c == '+') {
                int k = pop();
                int k2 = pop();
                push(k2 + k);
            } else if (c == '-') {
                int k = pop();
                int k2 = pop();
                push(k2 - k);
            } else if (c == '*') {
                int k = pop();
                int k2 = pop();
                push(k2 * k);
            } else {
                push(Integer.parseInt(s));
            }

        }
        System.out.println(pop());
        sc.close();
    } main {
        Scanner sc = new Scanner(System.in);
        s = new int[1000];
        while (sc.hasNext()) {
            String s = sc.next();
            char c = s.charAt(0);
            if (c == '+') {
                int k = pop();
                int k2 = pop();
                push(k2 + k);
            } else if (c == '-') {
                int k = pop();
                int k2 = pop();
                push(k2 - k);
            } else if (c == '*') {
                int k = pop();
                int k2 = pop();
                push(k2 * k);
            } else {
                push(Integer.parseInt(s));
            }

        }
        System.out.println(pop());
        sc.close();
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) s = new int[1000] s new int[1000] 1000 while (sc.hasNext()) {
            String s = sc.next();
            char c = s.charAt(0);
            if (c == '+') {
                int k = pop();
                int k2 = pop();
                push(k2 + k);
            } else if (c == '-') {
                int k = pop();
                int k2 = pop();
                push(k2 - k);
            } else if (c == '*') {
                int k = pop();
                int k2 = pop();
                push(k2 * k);
            } else {
                push(Integer.parseInt(s));
            }

        } sc.hasNext() sc.hasNext sc {
            String s = sc.next();
            char c = s.charAt(0);
            if (c == '+') {
                int k = pop();
                int k2 = pop();
                push(k2 + k);
            } else if (c == '-') {
                int k = pop();
                int k2 = pop();
                push(k2 - k);
            } else if (c == '*') {
                int k = pop();
                int k2 = pop();
                push(k2 * k);
            } else {
                push(Integer.parseInt(s));
            }

        } String s = sc.next(); s sc.next() sc.next sc char c = s.charAt(0); c s.charAt(0) s.charAt s 0 if (c == '+') {
                int k = pop();
                int k2 = pop();
                push(k2 + k);
            } else if (c == '-') {
                int k = pop();
                int k2 = pop();
                push(k2 - k);
            } else if (c == '*') {
                int k = pop();
                int k2 = pop();
                push(k2 * k);
            } else {
                push(Integer.parseInt(s));
            } c == '+' c '+' {
                int k = pop();
                int k2 = pop();
                push(k2 + k);
            } int k = pop(); k pop() pop int k2 = pop(); k2 pop() pop push(k2 + k) push k2 + k k2 k if (c == '-') {
                int k = pop();
                int k2 = pop();
                push(k2 - k);
            } else if (c == '*') {
                int k = pop();
                int k2 = pop();
                push(k2 * k);
            } else {
                push(Integer.parseInt(s));
            } c == '-' c '-' {
                int k = pop();
                int k2 = pop();
                push(k2 - k);
            } int k = pop(); k pop() pop int k2 = pop(); k2 pop() pop push(k2 - k) push k2 - k k2 k if (c == '*') {
                int k = pop();
                int k2 = pop();
                push(k2 * k);
            } else {
                push(Integer.parseInt(s));
            } c == '*' c '*' {
                int k = pop();
                int k2 = pop();
                push(k2 * k);
            } int k = pop(); k pop() pop int k2 = pop(); k2 pop() pop push(k2 * k) push k2 * k k2 k {
                push(Integer.parseInt(s));
            } push(Integer.parseInt(s)) push Integer.parseInt(s) Integer.parseInt Integer s System.out.println(pop()) System.out.println System.out System System.out pop() pop sc.close() sc.close sc String[] args args public class Main {

    static int top;
    static int[] s;

    static void push(int x) {
        s[++top] = x;
    }

    static int pop() {
        top--;
        return s[top + 1];
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        s = new int[1000];
        while (sc.hasNext()) {
            String s = sc.next();
            char c = s.charAt(0);
            if (c == '+') {
                int k = pop();
                int k2 = pop();
                push(k2 + k);
            } else if (c == '-') {
                int k = pop();
                int k2 = pop();
                push(k2 - k);
            } else if (c == '*') {
                int k = pop();
                int k2 = pop();
                push(k2 * k);
            } else {
                push(Integer.parseInt(s));
            }

        }
        System.out.println(pop());
        sc.close();
    }
} public class Main {

    static int top;
    static int[] s;

    static void push(int x) {
        s[++top] = x;
    }

    static int pop() {
        top--;
        return s[top + 1];
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        s = new int[1000];
        while (sc.hasNext()) {
            String s = sc.next();
            char c = s.charAt(0);
            if (c == '+') {
                int k = pop();
                int k2 = pop();
                push(k2 + k);
            } else if (c == '-') {
                int k = pop();
                int k2 = pop();
                push(k2 - k);
            } else if (c == '*') {
                int k = pop();
                int k2 = pop();
                push(k2 * k);
            } else {
                push(Integer.parseInt(s));
            }

        }
        System.out.println(pop());
        sc.close();
    }
} Main
import java.util.*;

public class Main {

    static int top;
    static int[] s;

    static void push(int x) {
        s[++top] = x;
    }

    static int pop() {
        top--;
        return s[top + 1];
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        s = new int[1000];
        while (sc.hasNext()) {
            String s = sc.next();
            char c = s.charAt(0);
            if (c == '+') {
                int k = pop();
                int k2 = pop();
                push(k2 + k);
            } else if (c == '-') {
                int k = pop();
                int k2 = pop();
                push(k2 - k);
            } else if (c == '*') {
                int k = pop();
                int k2 = pop();
                push(k2 * k);
            } else {
                push(Integer.parseInt(s));
            }

        }
        System.out.println(pop());
        sc.close();
    }
}
