import java.util.Scanner;
import java.util.Stack;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String[] ss = sc.nextLine().split(" ");
        Stack<String> st = new Stack<>();
        for (String s: ss) {
            int first, second, r;
            switch (s) {
                case "+":
                    first = Integer.parseInt(st.pop());
                    second = Integer.parseInt(st.pop());
                    r = second + first;
                    st.push(Integer.toString(r));
                    break;
                case "-":
                    first = Integer.parseInt(st.pop());
                    second = Integer.parseInt(st.pop());
                    r = second - first;
                    st.push(Integer.toString(r));
                    break;
                case "*":
                    first = Integer.parseInt(st.pop());
                    second = Integer.parseInt(st.pop());
                    r = second * first;
                    st.push(Integer.toString(r));
                    break;
                default:
                    st.push(s);
            }
        }
        assert(st.size() == 1);
        System.out.println(st.pop());
    }
}

 import java.util.Scanner; Scanner java.util import java.util.Stack; Stack java.util public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String[] ss = sc.nextLine().split(" ");
        Stack<String> st = new Stack<>();
        for (String s: ss) {
            int first, second, r;
            switch (s) {
                case "+":
                    first = Integer.parseInt(st.pop());
                    second = Integer.parseInt(st.pop());
                    r = second + first;
                    st.push(Integer.toString(r));
                    break;
                case "-":
                    first = Integer.parseInt(st.pop());
                    second = Integer.parseInt(st.pop());
                    r = second - first;
                    st.push(Integer.toString(r));
                    break;
                case "*":
                    first = Integer.parseInt(st.pop());
                    second = Integer.parseInt(st.pop());
                    r = second * first;
                    st.push(Integer.toString(r));
                    break;
                default:
                    st.push(s);
            }
        }
        assert(st.size() == 1);
        System.out.println(st.pop());
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String[] ss = sc.nextLine().split(" ");
        Stack<String> st = new Stack<>();
        for (String s: ss) {
            int first, second, r;
            switch (s) {
                case "+":
                    first = Integer.parseInt(st.pop());
                    second = Integer.parseInt(st.pop());
                    r = second + first;
                    st.push(Integer.toString(r));
                    break;
                case "-":
                    first = Integer.parseInt(st.pop());
                    second = Integer.parseInt(st.pop());
                    r = second - first;
                    st.push(Integer.toString(r));
                    break;
                case "*":
                    first = Integer.parseInt(st.pop());
                    second = Integer.parseInt(st.pop());
                    r = second * first;
                    st.push(Integer.toString(r));
                    break;
                default:
                    st.push(s);
            }
        }
        assert(st.size() == 1);
        System.out.println(st.pop());
    } main {
        Scanner sc = new Scanner(System.in);
        String[] ss = sc.nextLine().split(" ");
        Stack<String> st = new Stack<>();
        for (String s: ss) {
            int first, second, r;
            switch (s) {
                case "+":
                    first = Integer.parseInt(st.pop());
                    second = Integer.parseInt(st.pop());
                    r = second + first;
                    st.push(Integer.toString(r));
                    break;
                case "-":
                    first = Integer.parseInt(st.pop());
                    second = Integer.parseInt(st.pop());
                    r = second - first;
                    st.push(Integer.toString(r));
                    break;
                case "*":
                    first = Integer.parseInt(st.pop());
                    second = Integer.parseInt(st.pop());
                    r = second * first;
                    st.push(Integer.toString(r));
                    break;
                default:
                    st.push(s);
            }
        }
        assert(st.size() == 1);
        System.out.println(st.pop());
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String[] ss = sc.nextLine().split(" "); ss sc.nextLine().split(" ") sc.nextLine().split sc.nextLine() sc.nextLine sc " " Stack<String> st = new Stack<>(); st new Stack<>() for (String s: ss) {
            int first, second, r;
            switch (s) {
                case "+":
                    first = Integer.parseInt(st.pop());
                    second = Integer.parseInt(st.pop());
                    r = second + first;
                    st.push(Integer.toString(r));
                    break;
                case "-":
                    first = Integer.parseInt(st.pop());
                    second = Integer.parseInt(st.pop());
                    r = second - first;
                    st.push(Integer.toString(r));
                    break;
                case "*":
                    first = Integer.parseInt(st.pop());
                    second = Integer.parseInt(st.pop());
                    r = second * first;
                    st.push(Integer.toString(r));
                    break;
                default:
                    st.push(s);
            }
        } String s ss {
            int first, second, r;
            switch (s) {
                case "+":
                    first = Integer.parseInt(st.pop());
                    second = Integer.parseInt(st.pop());
                    r = second + first;
                    st.push(Integer.toString(r));
                    break;
                case "-":
                    first = Integer.parseInt(st.pop());
                    second = Integer.parseInt(st.pop());
                    r = second - first;
                    st.push(Integer.toString(r));
                    break;
                case "*":
                    first = Integer.parseInt(st.pop());
                    second = Integer.parseInt(st.pop());
                    r = second * first;
                    st.push(Integer.toString(r));
                    break;
                default:
                    st.push(s);
            }
        } {
            int first, second, r;
            switch (s) {
                case "+":
                    first = Integer.parseInt(st.pop());
                    second = Integer.parseInt(st.pop());
                    r = second + first;
                    st.push(Integer.toString(r));
                    break;
                case "-":
                    first = Integer.parseInt(st.pop());
                    second = Integer.parseInt(st.pop());
                    r = second - first;
                    st.push(Integer.toString(r));
                    break;
                case "*":
                    first = Integer.parseInt(st.pop());
                    second = Integer.parseInt(st.pop());
                    r = second * first;
                    st.push(Integer.toString(r));
                    break;
                default:
                    st.push(s);
            }
        } int first first second second r; r switch (s) {
                case "+":
                    first = Integer.parseInt(st.pop());
                    second = Integer.parseInt(st.pop());
                    r = second + first;
                    st.push(Integer.toString(r));
                    break;
                case "-":
                    first = Integer.parseInt(st.pop());
                    second = Integer.parseInt(st.pop());
                    r = second - first;
                    st.push(Integer.toString(r));
                    break;
                case "*":
                    first = Integer.parseInt(st.pop());
                    second = Integer.parseInt(st.pop());
                    r = second * first;
                    st.push(Integer.toString(r));
                    break;
                default:
                    st.push(s);
            } s case "+": "+" case "+": first = Integer.parseInt(st.pop()) first Integer.parseInt(st.pop()) Integer.parseInt Integer st.pop() st.pop st second = Integer.parseInt(st.pop()) second Integer.parseInt(st.pop()) Integer.parseInt Integer st.pop() st.pop st r = second + first r second + first second first st.push(Integer.toString(r)) st.push st Integer.toString(r) Integer.toString Integer r break; case "-": "-" case "-": first = Integer.parseInt(st.pop()) first Integer.parseInt(st.pop()) Integer.parseInt Integer st.pop() st.pop st second = Integer.parseInt(st.pop()) second Integer.parseInt(st.pop()) Integer.parseInt Integer st.pop() st.pop st r = second - first r second - first second first st.push(Integer.toString(r)) st.push st Integer.toString(r) Integer.toString Integer r break; case "*": "*" case "*": first = Integer.parseInt(st.pop()) first Integer.parseInt(st.pop()) Integer.parseInt Integer st.pop() st.pop st second = Integer.parseInt(st.pop()) second Integer.parseInt(st.pop()) Integer.parseInt Integer st.pop() st.pop st r = second * first r second * first second first st.push(Integer.toString(r)) st.push st Integer.toString(r) Integer.toString Integer r break; default: default: st.push(s) st.push st s System.out.println(st.pop()) System.out.println System.out System System.out st.pop() st.pop st String[] args args public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String[] ss = sc.nextLine().split(" ");
        Stack<String> st = new Stack<>();
        for (String s: ss) {
            int first, second, r;
            switch (s) {
                case "+":
                    first = Integer.parseInt(st.pop());
                    second = Integer.parseInt(st.pop());
                    r = second + first;
                    st.push(Integer.toString(r));
                    break;
                case "-":
                    first = Integer.parseInt(st.pop());
                    second = Integer.parseInt(st.pop());
                    r = second - first;
                    st.push(Integer.toString(r));
                    break;
                case "*":
                    first = Integer.parseInt(st.pop());
                    second = Integer.parseInt(st.pop());
                    r = second * first;
                    st.push(Integer.toString(r));
                    break;
                default:
                    st.push(s);
            }
        }
        assert(st.size() == 1);
        System.out.println(st.pop());
    }
} public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String[] ss = sc.nextLine().split(" ");
        Stack<String> st = new Stack<>();
        for (String s: ss) {
            int first, second, r;
            switch (s) {
                case "+":
                    first = Integer.parseInt(st.pop());
                    second = Integer.parseInt(st.pop());
                    r = second + first;
                    st.push(Integer.toString(r));
                    break;
                case "-":
                    first = Integer.parseInt(st.pop());
                    second = Integer.parseInt(st.pop());
                    r = second - first;
                    st.push(Integer.toString(r));
                    break;
                case "*":
                    first = Integer.parseInt(st.pop());
                    second = Integer.parseInt(st.pop());
                    r = second * first;
                    st.push(Integer.toString(r));
                    break;
                default:
                    st.push(s);
            }
        }
        assert(st.size() == 1);
        System.out.println(st.pop());
    }
} Main
import java.util.Scanner;
import java.util.Stack;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String[] ss = sc.nextLine().split(" ");
        Stack<String> st = new Stack<>();
        for (String s: ss) {
            int first, second, r;
            switch (s) {
                case "+":
                    first = Integer.parseInt(st.pop());
                    second = Integer.parseInt(st.pop());
                    r = second + first;
                    st.push(Integer.toString(r));
                    break;
                case "-":
                    first = Integer.parseInt(st.pop());
                    second = Integer.parseInt(st.pop());
                    r = second - first;
                    st.push(Integer.toString(r));
                    break;
                case "*":
                    first = Integer.parseInt(st.pop());
                    second = Integer.parseInt(st.pop());
                    r = second * first;
                    st.push(Integer.toString(r));
                    break;
                default:
                    st.push(s);
            }
        }
        assert(st.size() == 1);
        System.out.println(st.pop());
    }
}


