import java.util.*;

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

    static void aldl_1_3_a() {
        Scanner sc = new Scanner(System.in);
        String[] data = sc.nextLine().split(" ");
        sc.close();

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

        for (int i = 0; i < data.length; i++) {
            String value = data[i];
            int first, second;

            switch (value) {
                case "+":
                    first = stack.get(stack.size() - 2);
                    second = stack.get(stack.size() - 1);
                    int a = first + second;
                    stack.remove(stack.size() - 1);
                    stack.remove(stack.size() - 1);
                    stack.add(a);
                    break;
                case "-":
                    first = stack.get(stack.size() - 2);
                    second = stack.get(stack.size() - 1);
                    int b = first - second;
                    stack.remove(stack.size() - 1);
                    stack.remove(stack.size() - 1);
                    stack.add(b);
                    break;
                case "*":
                    first = stack.get(stack.size() - 2);
                    second = stack.get(stack.size() - 1);
                    int c = first * second;
                    stack.remove(stack.size() - 1);
                    stack.remove(stack.size() - 1);
                    stack.add(c);
                    break;
                default:
                    stack.add(Integer.parseInt(value));
                    break;
            }
        }
        System.out.println(stack.get(0));
    }
} import java.util.*; util.* java public class Main {
    public static void main(String[] args) {
        aldl_1_3_a();
    }

    static void aldl_1_3_a() {
        Scanner sc = new Scanner(System.in);
        String[] data = sc.nextLine().split(" ");
        sc.close();

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

        for (int i = 0; i < data.length; i++) {
            String value = data[i];
            int first, second;

            switch (value) {
                case "+":
                    first = stack.get(stack.size() - 2);
                    second = stack.get(stack.size() - 1);
                    int a = first + second;
                    stack.remove(stack.size() - 1);
                    stack.remove(stack.size() - 1);
                    stack.add(a);
                    break;
                case "-":
                    first = stack.get(stack.size() - 2);
                    second = stack.get(stack.size() - 1);
                    int b = first - second;
                    stack.remove(stack.size() - 1);
                    stack.remove(stack.size() - 1);
                    stack.add(b);
                    break;
                case "*":
                    first = stack.get(stack.size() - 2);
                    second = stack.get(stack.size() - 1);
                    int c = first * second;
                    stack.remove(stack.size() - 1);
                    stack.remove(stack.size() - 1);
                    stack.add(c);
                    break;
                default:
                    stack.add(Integer.parseInt(value));
                    break;
            }
        }
        System.out.println(stack.get(0));
    }
} Main public static void main(String[] args) {
        aldl_1_3_a();
    } main {
        aldl_1_3_a();
    } aldl_1_3_a() aldl_1_3_a String[] args args static void aldl_1_3_a() {
        Scanner sc = new Scanner(System.in);
        String[] data = sc.nextLine().split(" ");
        sc.close();

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

        for (int i = 0; i < data.length; i++) {
            String value = data[i];
            int first, second;

            switch (value) {
                case "+":
                    first = stack.get(stack.size() - 2);
                    second = stack.get(stack.size() - 1);
                    int a = first + second;
                    stack.remove(stack.size() - 1);
                    stack.remove(stack.size() - 1);
                    stack.add(a);
                    break;
                case "-":
                    first = stack.get(stack.size() - 2);
                    second = stack.get(stack.size() - 1);
                    int b = first - second;
                    stack.remove(stack.size() - 1);
                    stack.remove(stack.size() - 1);
                    stack.add(b);
                    break;
                case "*":
                    first = stack.get(stack.size() - 2);
                    second = stack.get(stack.size() - 1);
                    int c = first * second;
                    stack.remove(stack.size() - 1);
                    stack.remove(stack.size() - 1);
                    stack.add(c);
                    break;
                default:
                    stack.add(Integer.parseInt(value));
                    break;
            }
        }
        System.out.println(stack.get(0));
    } aldl_1_3_a {
        Scanner sc = new Scanner(System.in);
        String[] data = sc.nextLine().split(" ");
        sc.close();

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

        for (int i = 0; i < data.length; i++) {
            String value = data[i];
            int first, second;

            switch (value) {
                case "+":
                    first = stack.get(stack.size() - 2);
                    second = stack.get(stack.size() - 1);
                    int a = first + second;
                    stack.remove(stack.size() - 1);
                    stack.remove(stack.size() - 1);
                    stack.add(a);
                    break;
                case "-":
                    first = stack.get(stack.size() - 2);
                    second = stack.get(stack.size() - 1);
                    int b = first - second;
                    stack.remove(stack.size() - 1);
                    stack.remove(stack.size() - 1);
                    stack.add(b);
                    break;
                case "*":
                    first = stack.get(stack.size() - 2);
                    second = stack.get(stack.size() - 1);
                    int c = first * second;
                    stack.remove(stack.size() - 1);
                    stack.remove(stack.size() - 1);
                    stack.add(c);
                    break;
                default:
                    stack.add(Integer.parseInt(value));
                    break;
            }
        }
        System.out.println(stack.get(0));
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String[] data = sc.nextLine().split(" "); data sc.nextLine().split(" ") sc.nextLine().split sc.nextLine() sc.nextLine sc " " sc.close() sc.close sc ArrayList<Integer> stack = new ArrayList<Integer>(); stack new ArrayList<Integer>() for (int i = 0; i < data.length; i++) {
            String value = data[i];
            int first, second;

            switch (value) {
                case "+":
                    first = stack.get(stack.size() - 2);
                    second = stack.get(stack.size() - 1);
                    int a = first + second;
                    stack.remove(stack.size() - 1);
                    stack.remove(stack.size() - 1);
                    stack.add(a);
                    break;
                case "-":
                    first = stack.get(stack.size() - 2);
                    second = stack.get(stack.size() - 1);
                    int b = first - second;
                    stack.remove(stack.size() - 1);
                    stack.remove(stack.size() - 1);
                    stack.add(b);
                    break;
                case "*":
                    first = stack.get(stack.size() - 2);
                    second = stack.get(stack.size() - 1);
                    int c = first * second;
                    stack.remove(stack.size() - 1);
                    stack.remove(stack.size() - 1);
                    stack.add(c);
                    break;
                default:
                    stack.add(Integer.parseInt(value));
                    break;
            }
        } int i = 0; int i = 0; i 0 i < data.length i data.length data data.length i++ i++ i {
            String value = data[i];
            int first, second;

            switch (value) {
                case "+":
                    first = stack.get(stack.size() - 2);
                    second = stack.get(stack.size() - 1);
                    int a = first + second;
                    stack.remove(stack.size() - 1);
                    stack.remove(stack.size() - 1);
                    stack.add(a);
                    break;
                case "-":
                    first = stack.get(stack.size() - 2);
                    second = stack.get(stack.size() - 1);
                    int b = first - second;
                    stack.remove(stack.size() - 1);
                    stack.remove(stack.size() - 1);
                    stack.add(b);
                    break;
                case "*":
                    first = stack.get(stack.size() - 2);
                    second = stack.get(stack.size() - 1);
                    int c = first * second;
                    stack.remove(stack.size() - 1);
                    stack.remove(stack.size() - 1);
                    stack.add(c);
                    break;
                default:
                    stack.add(Integer.parseInt(value));
                    break;
            }
        } {
            String value = data[i];
            int first, second;

            switch (value) {
                case "+":
                    first = stack.get(stack.size() - 2);
                    second = stack.get(stack.size() - 1);
                    int a = first + second;
                    stack.remove(stack.size() - 1);
                    stack.remove(stack.size() - 1);
                    stack.add(a);
                    break;
                case "-":
                    first = stack.get(stack.size() - 2);
                    second = stack.get(stack.size() - 1);
                    int b = first - second;
                    stack.remove(stack.size() - 1);
                    stack.remove(stack.size() - 1);
                    stack.add(b);
                    break;
                case "*":
                    first = stack.get(stack.size() - 2);
                    second = stack.get(stack.size() - 1);
                    int c = first * second;
                    stack.remove(stack.size() - 1);
                    stack.remove(stack.size() - 1);
                    stack.add(c);
                    break;
                default:
                    stack.add(Integer.parseInt(value));
                    break;
            }
        } String value = data[i]; value data[i] data i int first first second; second switch (value) {
                case "+":
                    first = stack.get(stack.size() - 2);
                    second = stack.get(stack.size() - 1);
                    int a = first + second;
                    stack.remove(stack.size() - 1);
                    stack.remove(stack.size() - 1);
                    stack.add(a);
                    break;
                case "-":
                    first = stack.get(stack.size() - 2);
                    second = stack.get(stack.size() - 1);
                    int b = first - second;
                    stack.remove(stack.size() - 1);
                    stack.remove(stack.size() - 1);
                    stack.add(b);
                    break;
                case "*":
                    first = stack.get(stack.size() - 2);
                    second = stack.get(stack.size() - 1);
                    int c = first * second;
                    stack.remove(stack.size() - 1);
                    stack.remove(stack.size() - 1);
                    stack.add(c);
                    break;
                default:
                    stack.add(Integer.parseInt(value));
                    break;
            } value case "+": "+" case "+": first = stack.get(stack.size() - 2) first stack.get(stack.size() - 2) stack.get stack stack.size() - 2 stack.size() stack.size stack 2 second = stack.get(stack.size() - 1) second stack.get(stack.size() - 1) stack.get stack stack.size() - 1 stack.size() stack.size stack 1 int a = first + second; a first + second first second stack.remove(stack.size() - 1) stack.remove stack stack.size() - 1 stack.size() stack.size stack 1 stack.remove(stack.size() - 1) stack.remove stack stack.size() - 1 stack.size() stack.size stack 1 stack.add(a) stack.add stack a break; case "-": "-" case "-": first = stack.get(stack.size() - 2) first stack.get(stack.size() - 2) stack.get stack stack.size() - 2 stack.size() stack.size stack 2 second = stack.get(stack.size() - 1) second stack.get(stack.size() - 1) stack.get stack stack.size() - 1 stack.size() stack.size stack 1 int b = first - second; b first - second first second stack.remove(stack.size() - 1) stack.remove stack stack.size() - 1 stack.size() stack.size stack 1 stack.remove(stack.size() - 1) stack.remove stack stack.size() - 1 stack.size() stack.size stack 1 stack.add(b) stack.add stack b break; case "*": "*" case "*": first = stack.get(stack.size() - 2) first stack.get(stack.size() - 2) stack.get stack stack.size() - 2 stack.size() stack.size stack 2 second = stack.get(stack.size() - 1) second stack.get(stack.size() - 1) stack.get stack stack.size() - 1 stack.size() stack.size stack 1 int c = first * second; c first * second first second stack.remove(stack.size() - 1) stack.remove stack stack.size() - 1 stack.size() stack.size stack 1 stack.remove(stack.size() - 1) stack.remove stack stack.size() - 1 stack.size() stack.size stack 1 stack.add(c) stack.add stack c break; default: default: stack.add(Integer.parseInt(value)) stack.add stack Integer.parseInt(value) Integer.parseInt Integer value break; System.out.println(stack.get(0)) System.out.println System.out System System.out stack.get(0) stack.get stack 0 public class Main {
    public static void main(String[] args) {
        aldl_1_3_a();
    }

    static void aldl_1_3_a() {
        Scanner sc = new Scanner(System.in);
        String[] data = sc.nextLine().split(" ");
        sc.close();

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

        for (int i = 0; i < data.length; i++) {
            String value = data[i];
            int first, second;

            switch (value) {
                case "+":
                    first = stack.get(stack.size() - 2);
                    second = stack.get(stack.size() - 1);
                    int a = first + second;
                    stack.remove(stack.size() - 1);
                    stack.remove(stack.size() - 1);
                    stack.add(a);
                    break;
                case "-":
                    first = stack.get(stack.size() - 2);
                    second = stack.get(stack.size() - 1);
                    int b = first - second;
                    stack.remove(stack.size() - 1);
                    stack.remove(stack.size() - 1);
                    stack.add(b);
                    break;
                case "*":
                    first = stack.get(stack.size() - 2);
                    second = stack.get(stack.size() - 1);
                    int c = first * second;
                    stack.remove(stack.size() - 1);
                    stack.remove(stack.size() - 1);
                    stack.add(c);
                    break;
                default:
                    stack.add(Integer.parseInt(value));
                    break;
            }
        }
        System.out.println(stack.get(0));
    }
} public class Main {
    public static void main(String[] args) {
        aldl_1_3_a();
    }

    static void aldl_1_3_a() {
        Scanner sc = new Scanner(System.in);
        String[] data = sc.nextLine().split(" ");
        sc.close();

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

        for (int i = 0; i < data.length; i++) {
            String value = data[i];
            int first, second;

            switch (value) {
                case "+":
                    first = stack.get(stack.size() - 2);
                    second = stack.get(stack.size() - 1);
                    int a = first + second;
                    stack.remove(stack.size() - 1);
                    stack.remove(stack.size() - 1);
                    stack.add(a);
                    break;
                case "-":
                    first = stack.get(stack.size() - 2);
                    second = stack.get(stack.size() - 1);
                    int b = first - second;
                    stack.remove(stack.size() - 1);
                    stack.remove(stack.size() - 1);
                    stack.add(b);
                    break;
                case "*":
                    first = stack.get(stack.size() - 2);
                    second = stack.get(stack.size() - 1);
                    int c = first * second;
                    stack.remove(stack.size() - 1);
                    stack.remove(stack.size() - 1);
                    stack.add(c);
                    break;
                default:
                    stack.add(Integer.parseInt(value));
                    break;
            }
        }
        System.out.println(stack.get(0));
    }
} Main
import java.util.*;

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

    static void aldl_1_3_a() {
        Scanner sc = new Scanner(System.in);
        String[] data = sc.nextLine().split(" ");
        sc.close();

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

        for (int i = 0; i < data.length; i++) {
            String value = data[i];
            int first, second;

            switch (value) {
                case "+":
                    first = stack.get(stack.size() - 2);
                    second = stack.get(stack.size() - 1);
                    int a = first + second;
                    stack.remove(stack.size() - 1);
                    stack.remove(stack.size() - 1);
                    stack.add(a);
                    break;
                case "-":
                    first = stack.get(stack.size() - 2);
                    second = stack.get(stack.size() - 1);
                    int b = first - second;
                    stack.remove(stack.size() - 1);
                    stack.remove(stack.size() - 1);
                    stack.add(b);
                    break;
                case "*":
                    first = stack.get(stack.size() - 2);
                    second = stack.get(stack.size() - 1);
                    int c = first * second;
                    stack.remove(stack.size() - 1);
                    stack.remove(stack.size() - 1);
                    stack.add(c);
                    break;
                default:
                    stack.add(Integer.parseInt(value));
                    break;
            }
        }
        System.out.println(stack.get(0));
    }
}
