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

public class Main {
    public static void main(String args[]) {
        String s;

        Scanner sc = new Scanner(System.in);
        s = sc.nextLine();

        Scanner scn = new Scanner(s);

        Stack<Integer> stack = new Stack<Integer>();

        while (scn.hasNext()) {
            String op = scn.next();
            if (op.equals("+")) {
                int n = stack.pop() + stack.pop();
                stack.push(n);
            } else if (op.equals("-")) {
                int n = -1 * stack.pop() + stack.pop();
                stack.push(n);
            } else if (op.equals("*")) {
                int n = stack.pop() * stack.pop();
                stack.push(n);
            } else {
                stack.push(Integer.parseInt(op));
            }
        }

        System.out.println(stack.pop());
    }
} import java.io.*; io.* java import java.util.*; util.* java public class Main {
    public static void main(String args[]) {
        String s;

        Scanner sc = new Scanner(System.in);
        s = sc.nextLine();

        Scanner scn = new Scanner(s);

        Stack<Integer> stack = new Stack<Integer>();

        while (scn.hasNext()) {
            String op = scn.next();
            if (op.equals("+")) {
                int n = stack.pop() + stack.pop();
                stack.push(n);
            } else if (op.equals("-")) {
                int n = -1 * stack.pop() + stack.pop();
                stack.push(n);
            } else if (op.equals("*")) {
                int n = stack.pop() * stack.pop();
                stack.push(n);
            } else {
                stack.push(Integer.parseInt(op));
            }
        }

        System.out.println(stack.pop());
    }
} Main public static void main(String args[]) {
        String s;

        Scanner sc = new Scanner(System.in);
        s = sc.nextLine();

        Scanner scn = new Scanner(s);

        Stack<Integer> stack = new Stack<Integer>();

        while (scn.hasNext()) {
            String op = scn.next();
            if (op.equals("+")) {
                int n = stack.pop() + stack.pop();
                stack.push(n);
            } else if (op.equals("-")) {
                int n = -1 * stack.pop() + stack.pop();
                stack.push(n);
            } else if (op.equals("*")) {
                int n = stack.pop() * stack.pop();
                stack.push(n);
            } else {
                stack.push(Integer.parseInt(op));
            }
        }

        System.out.println(stack.pop());
    } main {
        String s;

        Scanner sc = new Scanner(System.in);
        s = sc.nextLine();

        Scanner scn = new Scanner(s);

        Stack<Integer> stack = new Stack<Integer>();

        while (scn.hasNext()) {
            String op = scn.next();
            if (op.equals("+")) {
                int n = stack.pop() + stack.pop();
                stack.push(n);
            } else if (op.equals("-")) {
                int n = -1 * stack.pop() + stack.pop();
                stack.push(n);
            } else if (op.equals("*")) {
                int n = stack.pop() * stack.pop();
                stack.push(n);
            } else {
                stack.push(Integer.parseInt(op));
            }
        }

        System.out.println(stack.pop());
    } String s; s Scanner sc = new Scanner(System.in); sc new Scanner(System.in) s = sc.nextLine() s sc.nextLine() sc.nextLine sc Scanner scn = new Scanner(s); scn new Scanner(s) Stack<Integer> stack = new Stack<Integer>(); stack new Stack<Integer>() while (scn.hasNext()) {
            String op = scn.next();
            if (op.equals("+")) {
                int n = stack.pop() + stack.pop();
                stack.push(n);
            } else if (op.equals("-")) {
                int n = -1 * stack.pop() + stack.pop();
                stack.push(n);
            } else if (op.equals("*")) {
                int n = stack.pop() * stack.pop();
                stack.push(n);
            } else {
                stack.push(Integer.parseInt(op));
            }
        } scn.hasNext() scn.hasNext scn {
            String op = scn.next();
            if (op.equals("+")) {
                int n = stack.pop() + stack.pop();
                stack.push(n);
            } else if (op.equals("-")) {
                int n = -1 * stack.pop() + stack.pop();
                stack.push(n);
            } else if (op.equals("*")) {
                int n = stack.pop() * stack.pop();
                stack.push(n);
            } else {
                stack.push(Integer.parseInt(op));
            }
        } String op = scn.next(); op scn.next() scn.next scn if (op.equals("+")) {
                int n = stack.pop() + stack.pop();
                stack.push(n);
            } else if (op.equals("-")) {
                int n = -1 * stack.pop() + stack.pop();
                stack.push(n);
            } else if (op.equals("*")) {
                int n = stack.pop() * stack.pop();
                stack.push(n);
            } else {
                stack.push(Integer.parseInt(op));
            } op.equals("+") op.equals op "+" {
                int n = stack.pop() + stack.pop();
                stack.push(n);
            } int n = stack.pop() + stack.pop(); n stack.pop() + stack.pop() stack.pop() stack.pop stack stack.pop() stack.pop stack stack.push(n) stack.push stack n if (op.equals("-")) {
                int n = -1 * stack.pop() + stack.pop();
                stack.push(n);
            } else if (op.equals("*")) {
                int n = stack.pop() * stack.pop();
                stack.push(n);
            } else {
                stack.push(Integer.parseInt(op));
            } op.equals("-") op.equals op "-" {
                int n = -1 * stack.pop() + stack.pop();
                stack.push(n);
            } int n = -1 * stack.pop() + stack.pop(); n -1 * stack.pop() + stack.pop() -1 * stack.pop() -1 1 stack.pop() stack.pop stack stack.pop() stack.pop stack stack.push(n) stack.push stack n if (op.equals("*")) {
                int n = stack.pop() * stack.pop();
                stack.push(n);
            } else {
                stack.push(Integer.parseInt(op));
            } op.equals("*") op.equals op "*" {
                int n = stack.pop() * stack.pop();
                stack.push(n);
            } int n = stack.pop() * stack.pop(); n stack.pop() * stack.pop() stack.pop() stack.pop stack stack.pop() stack.pop stack stack.push(n) stack.push stack n {
                stack.push(Integer.parseInt(op));
            } stack.push(Integer.parseInt(op)) stack.push stack Integer.parseInt(op) Integer.parseInt Integer op System.out.println(stack.pop()) System.out.println System.out System System.out stack.pop() stack.pop stack String args[] args public class Main {
    public static void main(String args[]) {
        String s;

        Scanner sc = new Scanner(System.in);
        s = sc.nextLine();

        Scanner scn = new Scanner(s);

        Stack<Integer> stack = new Stack<Integer>();

        while (scn.hasNext()) {
            String op = scn.next();
            if (op.equals("+")) {
                int n = stack.pop() + stack.pop();
                stack.push(n);
            } else if (op.equals("-")) {
                int n = -1 * stack.pop() + stack.pop();
                stack.push(n);
            } else if (op.equals("*")) {
                int n = stack.pop() * stack.pop();
                stack.push(n);
            } else {
                stack.push(Integer.parseInt(op));
            }
        }

        System.out.println(stack.pop());
    }
} public class Main {
    public static void main(String args[]) {
        String s;

        Scanner sc = new Scanner(System.in);
        s = sc.nextLine();

        Scanner scn = new Scanner(s);

        Stack<Integer> stack = new Stack<Integer>();

        while (scn.hasNext()) {
            String op = scn.next();
            if (op.equals("+")) {
                int n = stack.pop() + stack.pop();
                stack.push(n);
            } else if (op.equals("-")) {
                int n = -1 * stack.pop() + stack.pop();
                stack.push(n);
            } else if (op.equals("*")) {
                int n = stack.pop() * stack.pop();
                stack.push(n);
            } else {
                stack.push(Integer.parseInt(op));
            }
        }

        System.out.println(stack.pop());
    }
} Main
import java.io.*;
import java.util.*;

public class Main {
    public static void main(String args[]) {
        String s;

        Scanner sc = new Scanner(System.in);
        s = sc.nextLine();

        Scanner scn = new Scanner(s);

        Stack<Integer> stack = new Stack<Integer>();

        while (scn.hasNext()) {
            String op = scn.next();
            if (op.equals("+")) {
                int n = stack.pop() + stack.pop();
                stack.push(n);
            } else if (op.equals("-")) {
                int n = -1 * stack.pop() + stack.pop();
                stack.push(n);
            } else if (op.equals("*")) {
                int n = stack.pop() * stack.pop();
                stack.push(n);
            } else {
                stack.push(Integer.parseInt(op));
            }
        }

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