import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String[] line = sc.nextLine().split(" ");
        ArrayDeque<Integer> stack = new ArrayDeque<>();
        for (String x : line) {
            char c = x.charAt(0);
            if (c == '+' || c == '-' || c == '*') {
                int second = stack.pop();
                int first = stack.pop();
                if (c == '+') {
                    first += second;
                } else if (c == '-') {
                    first -= second;
                } else {
                    first *= second;
                }
                stack.push(first);
            } else {
                stack.push(Integer.parseInt(x));
            }
        }
       System.out.println(stack.pop());
    }
} import java.util.*; util.* java public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String[] line = sc.nextLine().split(" ");
        ArrayDeque<Integer> stack = new ArrayDeque<>();
        for (String x : line) {
            char c = x.charAt(0);
            if (c == '+' || c == '-' || c == '*') {
                int second = stack.pop();
                int first = stack.pop();
                if (c == '+') {
                    first += second;
                } else if (c == '-') {
                    first -= second;
                } else {
                    first *= second;
                }
                stack.push(first);
            } else {
                stack.push(Integer.parseInt(x));
            }
        }
       System.out.println(stack.pop());
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String[] line = sc.nextLine().split(" ");
        ArrayDeque<Integer> stack = new ArrayDeque<>();
        for (String x : line) {
            char c = x.charAt(0);
            if (c == '+' || c == '-' || c == '*') {
                int second = stack.pop();
                int first = stack.pop();
                if (c == '+') {
                    first += second;
                } else if (c == '-') {
                    first -= second;
                } else {
                    first *= second;
                }
                stack.push(first);
            } else {
                stack.push(Integer.parseInt(x));
            }
        }
       System.out.println(stack.pop());
    } main {
        Scanner sc = new Scanner(System.in);
        String[] line = sc.nextLine().split(" ");
        ArrayDeque<Integer> stack = new ArrayDeque<>();
        for (String x : line) {
            char c = x.charAt(0);
            if (c == '+' || c == '-' || c == '*') {
                int second = stack.pop();
                int first = stack.pop();
                if (c == '+') {
                    first += second;
                } else if (c == '-') {
                    first -= second;
                } else {
                    first *= second;
                }
                stack.push(first);
            } else {
                stack.push(Integer.parseInt(x));
            }
        }
       System.out.println(stack.pop());
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String[] line = sc.nextLine().split(" "); line sc.nextLine().split(" ") sc.nextLine().split sc.nextLine() sc.nextLine sc " " ArrayDeque<Integer> stack = new ArrayDeque<>(); stack new ArrayDeque<>() for (String x : line) {
            char c = x.charAt(0);
            if (c == '+' || c == '-' || c == '*') {
                int second = stack.pop();
                int first = stack.pop();
                if (c == '+') {
                    first += second;
                } else if (c == '-') {
                    first -= second;
                } else {
                    first *= second;
                }
                stack.push(first);
            } else {
                stack.push(Integer.parseInt(x));
            }
        } String x line {
            char c = x.charAt(0);
            if (c == '+' || c == '-' || c == '*') {
                int second = stack.pop();
                int first = stack.pop();
                if (c == '+') {
                    first += second;
                } else if (c == '-') {
                    first -= second;
                } else {
                    first *= second;
                }
                stack.push(first);
            } else {
                stack.push(Integer.parseInt(x));
            }
        } {
            char c = x.charAt(0);
            if (c == '+' || c == '-' || c == '*') {
                int second = stack.pop();
                int first = stack.pop();
                if (c == '+') {
                    first += second;
                } else if (c == '-') {
                    first -= second;
                } else {
                    first *= second;
                }
                stack.push(first);
            } else {
                stack.push(Integer.parseInt(x));
            }
        } char c = x.charAt(0); c x.charAt(0) x.charAt x 0 if (c == '+' || c == '-' || c == '*') {
                int second = stack.pop();
                int first = stack.pop();
                if (c == '+') {
                    first += second;
                } else if (c == '-') {
                    first -= second;
                } else {
                    first *= second;
                }
                stack.push(first);
            } else {
                stack.push(Integer.parseInt(x));
            } c == '+' || c == '-' || c == '*' c == '+' || c == '-' || c == '*' c == '+' c '+' c == '-' c '-' c == '*' c '*' {
                int second = stack.pop();
                int first = stack.pop();
                if (c == '+') {
                    first += second;
                } else if (c == '-') {
                    first -= second;
                } else {
                    first *= second;
                }
                stack.push(first);
            } int second = stack.pop(); second stack.pop() stack.pop stack int first = stack.pop(); first stack.pop() stack.pop stack if (c == '+') {
                    first += second;
                } else if (c == '-') {
                    first -= second;
                } else {
                    first *= second;
                } c == '+' c '+' {
                    first += second;
                } first += second first second if (c == '-') {
                    first -= second;
                } else {
                    first *= second;
                } c == '-' c '-' {
                    first -= second;
                } first -= second first second {
                    first *= second;
                } first *= second first second stack.push(first) stack.push stack first {
                stack.push(Integer.parseInt(x));
            } stack.push(Integer.parseInt(x)) stack.push stack Integer.parseInt(x) Integer.parseInt Integer x 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) {
        Scanner sc = new Scanner(System.in);
        String[] line = sc.nextLine().split(" ");
        ArrayDeque<Integer> stack = new ArrayDeque<>();
        for (String x : line) {
            char c = x.charAt(0);
            if (c == '+' || c == '-' || c == '*') {
                int second = stack.pop();
                int first = stack.pop();
                if (c == '+') {
                    first += second;
                } else if (c == '-') {
                    first -= second;
                } else {
                    first *= second;
                }
                stack.push(first);
            } else {
                stack.push(Integer.parseInt(x));
            }
        }
       System.out.println(stack.pop());
    }
} public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String[] line = sc.nextLine().split(" ");
        ArrayDeque<Integer> stack = new ArrayDeque<>();
        for (String x : line) {
            char c = x.charAt(0);
            if (c == '+' || c == '-' || c == '*') {
                int second = stack.pop();
                int first = stack.pop();
                if (c == '+') {
                    first += second;
                } else if (c == '-') {
                    first -= second;
                } else {
                    first *= second;
                }
                stack.push(first);
            } else {
                stack.push(Integer.parseInt(x));
            }
        }
       System.out.println(stack.pop());
    }
} Main
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String[] line = sc.nextLine().split(" ");
        ArrayDeque<Integer> stack = new ArrayDeque<>();
        for (String x : line) {
            char c = x.charAt(0);
            if (c == '+' || c == '-' || c == '*') {
                int second = stack.pop();
                int first = stack.pop();
                if (c == '+') {
                    first += second;
                } else if (c == '-') {
                    first -= second;
                } else {
                    first *= second;
                }
                stack.push(first);
            } else {
                stack.push(Integer.parseInt(x));
            }
        }
       System.out.println(stack.pop());
    }
}
