import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        Stack stack = new Stack();
        for (String s : scanner.nextLine().split(" ")) {
            if ("+".equals(s)) {
                stack.push(stack.pop() + stack.pop());
            } else if ("-".equals(s)) {
                int i1 = stack.pop();
                int i2 = stack.pop();
                stack.push(i2 - i1);
            } else if ("*".equals(s)) {
                stack.push(stack.pop() * stack.pop());
            } else {
                stack.push(Integer.parseInt(s));
            }
        }
        System.out.println(stack.pop());
    }

    private static class Stack {
        private static class Node {
            int i;
            Node next;

            public Node(int i, Node next) {
                this.i = i;
                this.next = next;
            }
        }

        Node top;

        public void push(int i) {
            top = new Node(i, top);
        }

        public int pop() {
            int i = top.i;
            top = top.next;
            return i;
        }
    }
} import java.util.ArrayList; ArrayList java.util import java.util.List; List java.util import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        Stack stack = new Stack();
        for (String s : scanner.nextLine().split(" ")) {
            if ("+".equals(s)) {
                stack.push(stack.pop() + stack.pop());
            } else if ("-".equals(s)) {
                int i1 = stack.pop();
                int i2 = stack.pop();
                stack.push(i2 - i1);
            } else if ("*".equals(s)) {
                stack.push(stack.pop() * stack.pop());
            } else {
                stack.push(Integer.parseInt(s));
            }
        }
        System.out.println(stack.pop());
    }

    private static class Stack {
        private static class Node {
            int i;
            Node next;

            public Node(int i, Node next) {
                this.i = i;
                this.next = next;
            }
        }

        Node top;

        public void push(int i) {
            top = new Node(i, top);
        }

        public int pop() {
            int i = top.i;
            top = top.next;
            return i;
        }
    }
} Main public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        Stack stack = new Stack();
        for (String s : scanner.nextLine().split(" ")) {
            if ("+".equals(s)) {
                stack.push(stack.pop() + stack.pop());
            } else if ("-".equals(s)) {
                int i1 = stack.pop();
                int i2 = stack.pop();
                stack.push(i2 - i1);
            } else if ("*".equals(s)) {
                stack.push(stack.pop() * stack.pop());
            } else {
                stack.push(Integer.parseInt(s));
            }
        }
        System.out.println(stack.pop());
    } main {
        Scanner scanner = new Scanner(System.in);
        Stack stack = new Stack();
        for (String s : scanner.nextLine().split(" ")) {
            if ("+".equals(s)) {
                stack.push(stack.pop() + stack.pop());
            } else if ("-".equals(s)) {
                int i1 = stack.pop();
                int i2 = stack.pop();
                stack.push(i2 - i1);
            } else if ("*".equals(s)) {
                stack.push(stack.pop() * stack.pop());
            } else {
                stack.push(Integer.parseInt(s));
            }
        }
        System.out.println(stack.pop());
    } Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) Stack stack = new Stack(); stack new Stack() for (String s : scanner.nextLine().split(" ")) {
            if ("+".equals(s)) {
                stack.push(stack.pop() + stack.pop());
            } else if ("-".equals(s)) {
                int i1 = stack.pop();
                int i2 = stack.pop();
                stack.push(i2 - i1);
            } else if ("*".equals(s)) {
                stack.push(stack.pop() * stack.pop());
            } else {
                stack.push(Integer.parseInt(s));
            }
        } String s scanner.nextLine().split(" ") scanner.nextLine().split scanner.nextLine() scanner.nextLine scanner " " {
            if ("+".equals(s)) {
                stack.push(stack.pop() + stack.pop());
            } else if ("-".equals(s)) {
                int i1 = stack.pop();
                int i2 = stack.pop();
                stack.push(i2 - i1);
            } else if ("*".equals(s)) {
                stack.push(stack.pop() * stack.pop());
            } else {
                stack.push(Integer.parseInt(s));
            }
        } {
            if ("+".equals(s)) {
                stack.push(stack.pop() + stack.pop());
            } else if ("-".equals(s)) {
                int i1 = stack.pop();
                int i2 = stack.pop();
                stack.push(i2 - i1);
            } else if ("*".equals(s)) {
                stack.push(stack.pop() * stack.pop());
            } else {
                stack.push(Integer.parseInt(s));
            }
        } if ("+".equals(s)) {
                stack.push(stack.pop() + stack.pop());
            } else if ("-".equals(s)) {
                int i1 = stack.pop();
                int i2 = stack.pop();
                stack.push(i2 - i1);
            } else if ("*".equals(s)) {
                stack.push(stack.pop() * stack.pop());
            } else {
                stack.push(Integer.parseInt(s));
            } "+".equals(s) "+".equals "+" s {
                stack.push(stack.pop() + stack.pop());
            } stack.push(stack.pop() + stack.pop()) stack.push stack stack.pop() + stack.pop() stack.pop() stack.pop stack stack.pop() stack.pop stack if ("-".equals(s)) {
                int i1 = stack.pop();
                int i2 = stack.pop();
                stack.push(i2 - i1);
            } else if ("*".equals(s)) {
                stack.push(stack.pop() * stack.pop());
            } else {
                stack.push(Integer.parseInt(s));
            } "-".equals(s) "-".equals "-" s {
                int i1 = stack.pop();
                int i2 = stack.pop();
                stack.push(i2 - i1);
            } int i1 = stack.pop(); i1 stack.pop() stack.pop stack int i2 = stack.pop(); i2 stack.pop() stack.pop stack stack.push(i2 - i1) stack.push stack i2 - i1 i2 i1 if ("*".equals(s)) {
                stack.push(stack.pop() * stack.pop());
            } else {
                stack.push(Integer.parseInt(s));
            } "*".equals(s) "*".equals "*" s {
                stack.push(stack.pop() * stack.pop());
            } stack.push(stack.pop() * stack.pop()) stack.push stack stack.pop() * stack.pop() stack.pop() stack.pop stack stack.pop() stack.pop stack {
                stack.push(Integer.parseInt(s));
            } stack.push(Integer.parseInt(s)) stack.push stack Integer.parseInt(s) Integer.parseInt Integer s System.out.println(stack.pop()) System.out.println System.out System System.out stack.pop() stack.pop stack String[] args args private static class Stack {
        private static class Node {
            int i;
            Node next;

            public Node(int i, Node next) {
                this.i = i;
                this.next = next;
            }
        }

        Node top;

        public void push(int i) {
            top = new Node(i, top);
        }

        public int pop() {
            int i = top.i;
            top = top.next;
            return i;
        }
    } Stack Node top; top public void push(int i) {
            top = new Node(i, top);
        } push {
            top = new Node(i, top);
        } top = new Node(i, top) top new Node(i, top) int i i public int pop() {
            int i = top.i;
            top = top.next;
            return i;
        } pop {
            int i = top.i;
            top = top.next;
            return i;
        } int i = top.i; i top.i top top.i top = top.next top top.next top top.next return i; i private static class Node {
            int i;
            Node next;

            public Node(int i, Node next) {
                this.i = i;
                this.next = next;
            }
        } Node int i; i Node next; next public Node(int i, Node next) {
                this.i = i;
                this.next = next;
            } Node {
                this.i = i;
                this.next = next;
            } this.i = i this.i this this.i i this.next = next this.next this this.next next int i i Node next next public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        Stack stack = new Stack();
        for (String s : scanner.nextLine().split(" ")) {
            if ("+".equals(s)) {
                stack.push(stack.pop() + stack.pop());
            } else if ("-".equals(s)) {
                int i1 = stack.pop();
                int i2 = stack.pop();
                stack.push(i2 - i1);
            } else if ("*".equals(s)) {
                stack.push(stack.pop() * stack.pop());
            } else {
                stack.push(Integer.parseInt(s));
            }
        }
        System.out.println(stack.pop());
    }

    private static class Stack {
        private static class Node {
            int i;
            Node next;

            public Node(int i, Node next) {
                this.i = i;
                this.next = next;
            }
        }

        Node top;

        public void push(int i) {
            top = new Node(i, top);
        }

        public int pop() {
            int i = top.i;
            top = top.next;
            return i;
        }
    }
} public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        Stack stack = new Stack();
        for (String s : scanner.nextLine().split(" ")) {
            if ("+".equals(s)) {
                stack.push(stack.pop() + stack.pop());
            } else if ("-".equals(s)) {
                int i1 = stack.pop();
                int i2 = stack.pop();
                stack.push(i2 - i1);
            } else if ("*".equals(s)) {
                stack.push(stack.pop() * stack.pop());
            } else {
                stack.push(Integer.parseInt(s));
            }
        }
        System.out.println(stack.pop());
    }

    private static class Stack {
        private static class Node {
            int i;
            Node next;

            public Node(int i, Node next) {
                this.i = i;
                this.next = next;
            }
        }

        Node top;

        public void push(int i) {
            top = new Node(i, top);
        }

        public int pop() {
            int i = top.i;
            top = top.next;
            return i;
        }
    }
} Main
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        Stack stack = new Stack();
        for (String s : scanner.nextLine().split(" ")) {
            if ("+".equals(s)) {
                stack.push(stack.pop() + stack.pop());
            } else if ("-".equals(s)) {
                int i1 = stack.pop();
                int i2 = stack.pop();
                stack.push(i2 - i1);
            } else if ("*".equals(s)) {
                stack.push(stack.pop() * stack.pop());
            } else {
                stack.push(Integer.parseInt(s));
            }
        }
        System.out.println(stack.pop());
    }

    private static class Stack {
        private static class Node {
            int i;
            Node next;

            public Node(int i, Node next) {
                this.i = i;
                this.next = next;
            }
        }

        Node top;

        public void push(int i) {
            top = new Node(i, top);
        }

        public int pop() {
            int i = top.i;
            top = top.next;
            return i;
        }
    }
}