import java.util.ArrayDeque;
import java.util.Deque;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        new Main().solve();
    }

    private Scanner sc;

    private void solve() {
        sc = new Scanner(System.in);
        Deque<String> stack = new ArrayDeque<String>();
        String line = sc.nextLine();
        String[] a = line.split(" ");
        for (String s : a) {
            if ("+".equals(s)) {
                int n1 = Integer.parseInt(stack.pop());
                int n2 = Integer.parseInt(stack.pop());
                stack.push(String.valueOf(n1 + n2));
            } else if ("-".equals(s)) {
                int n1 = Integer.parseInt(stack.pop());
                int n2 = Integer.parseInt(stack.pop());
                stack.push(String.valueOf(n2 - n1));
            } else if ("*".equals(s)) {
                int n1 = Integer.parseInt(stack.pop());
                int n2 = Integer.parseInt(stack.pop());
                stack.push(String.valueOf(n1 * n2));
            } else {
                stack.push(s);
            }
        }
        System.out.println(stack.pop());
    }
} import java.util.ArrayDeque; ArrayDeque java.util import java.util.Deque; Deque java.util import java.util.Scanner; Scanner java.util public class Main {

    public static void main(String[] args) {
        new Main().solve();
    }

    private Scanner sc;

    private void solve() {
        sc = new Scanner(System.in);
        Deque<String> stack = new ArrayDeque<String>();
        String line = sc.nextLine();
        String[] a = line.split(" ");
        for (String s : a) {
            if ("+".equals(s)) {
                int n1 = Integer.parseInt(stack.pop());
                int n2 = Integer.parseInt(stack.pop());
                stack.push(String.valueOf(n1 + n2));
            } else if ("-".equals(s)) {
                int n1 = Integer.parseInt(stack.pop());
                int n2 = Integer.parseInt(stack.pop());
                stack.push(String.valueOf(n2 - n1));
            } else if ("*".equals(s)) {
                int n1 = Integer.parseInt(stack.pop());
                int n2 = Integer.parseInt(stack.pop());
                stack.push(String.valueOf(n1 * n2));
            } else {
                stack.push(s);
            }
        }
        System.out.println(stack.pop());
    }
} Main private Scanner sc; sc public static void main(String[] args) {
        new Main().solve();
    } main {
        new Main().solve();
    } new Main().solve() new Main().solve new Main() String[] args args private void solve() {
        sc = new Scanner(System.in);
        Deque<String> stack = new ArrayDeque<String>();
        String line = sc.nextLine();
        String[] a = line.split(" ");
        for (String s : a) {
            if ("+".equals(s)) {
                int n1 = Integer.parseInt(stack.pop());
                int n2 = Integer.parseInt(stack.pop());
                stack.push(String.valueOf(n1 + n2));
            } else if ("-".equals(s)) {
                int n1 = Integer.parseInt(stack.pop());
                int n2 = Integer.parseInt(stack.pop());
                stack.push(String.valueOf(n2 - n1));
            } else if ("*".equals(s)) {
                int n1 = Integer.parseInt(stack.pop());
                int n2 = Integer.parseInt(stack.pop());
                stack.push(String.valueOf(n1 * n2));
            } else {
                stack.push(s);
            }
        }
        System.out.println(stack.pop());
    } solve {
        sc = new Scanner(System.in);
        Deque<String> stack = new ArrayDeque<String>();
        String line = sc.nextLine();
        String[] a = line.split(" ");
        for (String s : a) {
            if ("+".equals(s)) {
                int n1 = Integer.parseInt(stack.pop());
                int n2 = Integer.parseInt(stack.pop());
                stack.push(String.valueOf(n1 + n2));
            } else if ("-".equals(s)) {
                int n1 = Integer.parseInt(stack.pop());
                int n2 = Integer.parseInt(stack.pop());
                stack.push(String.valueOf(n2 - n1));
            } else if ("*".equals(s)) {
                int n1 = Integer.parseInt(stack.pop());
                int n2 = Integer.parseInt(stack.pop());
                stack.push(String.valueOf(n1 * n2));
            } else {
                stack.push(s);
            }
        }
        System.out.println(stack.pop());
    } sc = new Scanner(System.in) sc new Scanner(System.in) Deque<String> stack = new ArrayDeque<String>(); stack new ArrayDeque<String>() String line = sc.nextLine(); line sc.nextLine() sc.nextLine sc String[] a = line.split(" "); a line.split(" ") line.split line " " for (String s : a) {
            if ("+".equals(s)) {
                int n1 = Integer.parseInt(stack.pop());
                int n2 = Integer.parseInt(stack.pop());
                stack.push(String.valueOf(n1 + n2));
            } else if ("-".equals(s)) {
                int n1 = Integer.parseInt(stack.pop());
                int n2 = Integer.parseInt(stack.pop());
                stack.push(String.valueOf(n2 - n1));
            } else if ("*".equals(s)) {
                int n1 = Integer.parseInt(stack.pop());
                int n2 = Integer.parseInt(stack.pop());
                stack.push(String.valueOf(n1 * n2));
            } else {
                stack.push(s);
            }
        } String s a {
            if ("+".equals(s)) {
                int n1 = Integer.parseInt(stack.pop());
                int n2 = Integer.parseInt(stack.pop());
                stack.push(String.valueOf(n1 + n2));
            } else if ("-".equals(s)) {
                int n1 = Integer.parseInt(stack.pop());
                int n2 = Integer.parseInt(stack.pop());
                stack.push(String.valueOf(n2 - n1));
            } else if ("*".equals(s)) {
                int n1 = Integer.parseInt(stack.pop());
                int n2 = Integer.parseInt(stack.pop());
                stack.push(String.valueOf(n1 * n2));
            } else {
                stack.push(s);
            }
        } {
            if ("+".equals(s)) {
                int n1 = Integer.parseInt(stack.pop());
                int n2 = Integer.parseInt(stack.pop());
                stack.push(String.valueOf(n1 + n2));
            } else if ("-".equals(s)) {
                int n1 = Integer.parseInt(stack.pop());
                int n2 = Integer.parseInt(stack.pop());
                stack.push(String.valueOf(n2 - n1));
            } else if ("*".equals(s)) {
                int n1 = Integer.parseInt(stack.pop());
                int n2 = Integer.parseInt(stack.pop());
                stack.push(String.valueOf(n1 * n2));
            } else {
                stack.push(s);
            }
        } if ("+".equals(s)) {
                int n1 = Integer.parseInt(stack.pop());
                int n2 = Integer.parseInt(stack.pop());
                stack.push(String.valueOf(n1 + n2));
            } else if ("-".equals(s)) {
                int n1 = Integer.parseInt(stack.pop());
                int n2 = Integer.parseInt(stack.pop());
                stack.push(String.valueOf(n2 - n1));
            } else if ("*".equals(s)) {
                int n1 = Integer.parseInt(stack.pop());
                int n2 = Integer.parseInt(stack.pop());
                stack.push(String.valueOf(n1 * n2));
            } else {
                stack.push(s);
            } "+".equals(s) "+".equals "+" s {
                int n1 = Integer.parseInt(stack.pop());
                int n2 = Integer.parseInt(stack.pop());
                stack.push(String.valueOf(n1 + n2));
            } int n1 = Integer.parseInt(stack.pop()); n1 Integer.parseInt(stack.pop()) Integer.parseInt Integer stack.pop() stack.pop stack int n2 = Integer.parseInt(stack.pop()); n2 Integer.parseInt(stack.pop()) Integer.parseInt Integer stack.pop() stack.pop stack stack.push(String.valueOf(n1 + n2)) stack.push stack String.valueOf(n1 + n2) String.valueOf String n1 + n2 n1 n2 if ("-".equals(s)) {
                int n1 = Integer.parseInt(stack.pop());
                int n2 = Integer.parseInt(stack.pop());
                stack.push(String.valueOf(n2 - n1));
            } else if ("*".equals(s)) {
                int n1 = Integer.parseInt(stack.pop());
                int n2 = Integer.parseInt(stack.pop());
                stack.push(String.valueOf(n1 * n2));
            } else {
                stack.push(s);
            } "-".equals(s) "-".equals "-" s {
                int n1 = Integer.parseInt(stack.pop());
                int n2 = Integer.parseInt(stack.pop());
                stack.push(String.valueOf(n2 - n1));
            } int n1 = Integer.parseInt(stack.pop()); n1 Integer.parseInt(stack.pop()) Integer.parseInt Integer stack.pop() stack.pop stack int n2 = Integer.parseInt(stack.pop()); n2 Integer.parseInt(stack.pop()) Integer.parseInt Integer stack.pop() stack.pop stack stack.push(String.valueOf(n2 - n1)) stack.push stack String.valueOf(n2 - n1) String.valueOf String n2 - n1 n2 n1 if ("*".equals(s)) {
                int n1 = Integer.parseInt(stack.pop());
                int n2 = Integer.parseInt(stack.pop());
                stack.push(String.valueOf(n1 * n2));
            } else {
                stack.push(s);
            } "*".equals(s) "*".equals "*" s {
                int n1 = Integer.parseInt(stack.pop());
                int n2 = Integer.parseInt(stack.pop());
                stack.push(String.valueOf(n1 * n2));
            } int n1 = Integer.parseInt(stack.pop()); n1 Integer.parseInt(stack.pop()) Integer.parseInt Integer stack.pop() stack.pop stack int n2 = Integer.parseInt(stack.pop()); n2 Integer.parseInt(stack.pop()) Integer.parseInt Integer stack.pop() stack.pop stack stack.push(String.valueOf(n1 * n2)) stack.push stack String.valueOf(n1 * n2) String.valueOf String n1 * n2 n1 n2 {
                stack.push(s);
            } stack.push(s) stack.push stack s System.out.println(stack.pop()) System.out.println System.out System System.out stack.pop() stack.pop stack public class Main {

    public static void main(String[] args) {
        new Main().solve();
    }

    private Scanner sc;

    private void solve() {
        sc = new Scanner(System.in);
        Deque<String> stack = new ArrayDeque<String>();
        String line = sc.nextLine();
        String[] a = line.split(" ");
        for (String s : a) {
            if ("+".equals(s)) {
                int n1 = Integer.parseInt(stack.pop());
                int n2 = Integer.parseInt(stack.pop());
                stack.push(String.valueOf(n1 + n2));
            } else if ("-".equals(s)) {
                int n1 = Integer.parseInt(stack.pop());
                int n2 = Integer.parseInt(stack.pop());
                stack.push(String.valueOf(n2 - n1));
            } else if ("*".equals(s)) {
                int n1 = Integer.parseInt(stack.pop());
                int n2 = Integer.parseInt(stack.pop());
                stack.push(String.valueOf(n1 * n2));
            } else {
                stack.push(s);
            }
        }
        System.out.println(stack.pop());
    }
} public class Main {

    public static void main(String[] args) {
        new Main().solve();
    }

    private Scanner sc;

    private void solve() {
        sc = new Scanner(System.in);
        Deque<String> stack = new ArrayDeque<String>();
        String line = sc.nextLine();
        String[] a = line.split(" ");
        for (String s : a) {
            if ("+".equals(s)) {
                int n1 = Integer.parseInt(stack.pop());
                int n2 = Integer.parseInt(stack.pop());
                stack.push(String.valueOf(n1 + n2));
            } else if ("-".equals(s)) {
                int n1 = Integer.parseInt(stack.pop());
                int n2 = Integer.parseInt(stack.pop());
                stack.push(String.valueOf(n2 - n1));
            } else if ("*".equals(s)) {
                int n1 = Integer.parseInt(stack.pop());
                int n2 = Integer.parseInt(stack.pop());
                stack.push(String.valueOf(n1 * n2));
            } else {
                stack.push(s);
            }
        }
        System.out.println(stack.pop());
    }
} Main
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        new Main().solve();
    }

    private Scanner sc;

    private void solve() {
        sc = new Scanner(System.in);
        Deque<String> stack = new ArrayDeque<String>();
        String line = sc.nextLine();
        String[] a = line.split(" ");
        for (String s : a) {
            if ("+".equals(s)) {
                int n1 = Integer.parseInt(stack.pop());
                int n2 = Integer.parseInt(stack.pop());
                stack.push(String.valueOf(n1 + n2));
            } else if ("-".equals(s)) {
                int n1 = Integer.parseInt(stack.pop());
                int n2 = Integer.parseInt(stack.pop());
                stack.push(String.valueOf(n2 - n1));
            } else if ("*".equals(s)) {
                int n1 = Integer.parseInt(stack.pop());
                int n2 = Integer.parseInt(stack.pop());
                stack.push(String.valueOf(n1 * n2));
            } else {
                stack.push(s);
            }
        }
        System.out.println(stack.pop());
    }
}