import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String line = in.nextLine();
        Scanner opt = new Scanner(line);
        int num1, num2;
        Stack num = new Stack();
        while (opt.hasNext()) {
            String c = opt.next();
            if (c.equals("+")) {
                num1 = num.pop();
                num2 = num.pop();
                num.push(num1 + num2);
            } else if (c.equals("-")) {
                num1 = num.pop();
                num2 = num.pop();
                num.push(num2 - num1);
            } else if (c.equals("*")) {
                num1 = num.pop();
                num2 = num.pop();
                num.push(num1 * num2);
            } else {
                num.push(Integer.parseInt(c));
            }
        }
        System.out.println(num.pop());
    }
}

class Stack {
    int top;
    int[] stack;

    public Stack() {
        this.top = 0;
        this.stack = new int[1000];
    }

    public void push(int num) {
        this.top++;
        this.stack[top] = num;
    }

    public int pop() {
        int num = this.stack[this.top];
        this.stack[this.top] = 0;
        this.top--;
        return num;
    }
} import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String line = in.nextLine();
        Scanner opt = new Scanner(line);
        int num1, num2;
        Stack num = new Stack();
        while (opt.hasNext()) {
            String c = opt.next();
            if (c.equals("+")) {
                num1 = num.pop();
                num2 = num.pop();
                num.push(num1 + num2);
            } else if (c.equals("-")) {
                num1 = num.pop();
                num2 = num.pop();
                num.push(num2 - num1);
            } else if (c.equals("*")) {
                num1 = num.pop();
                num2 = num.pop();
                num.push(num1 * num2);
            } else {
                num.push(Integer.parseInt(c));
            }
        }
        System.out.println(num.pop());
    }
} Main public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String line = in.nextLine();
        Scanner opt = new Scanner(line);
        int num1, num2;
        Stack num = new Stack();
        while (opt.hasNext()) {
            String c = opt.next();
            if (c.equals("+")) {
                num1 = num.pop();
                num2 = num.pop();
                num.push(num1 + num2);
            } else if (c.equals("-")) {
                num1 = num.pop();
                num2 = num.pop();
                num.push(num2 - num1);
            } else if (c.equals("*")) {
                num1 = num.pop();
                num2 = num.pop();
                num.push(num1 * num2);
            } else {
                num.push(Integer.parseInt(c));
            }
        }
        System.out.println(num.pop());
    } main {
        Scanner in = new Scanner(System.in);
        String line = in.nextLine();
        Scanner opt = new Scanner(line);
        int num1, num2;
        Stack num = new Stack();
        while (opt.hasNext()) {
            String c = opt.next();
            if (c.equals("+")) {
                num1 = num.pop();
                num2 = num.pop();
                num.push(num1 + num2);
            } else if (c.equals("-")) {
                num1 = num.pop();
                num2 = num.pop();
                num.push(num2 - num1);
            } else if (c.equals("*")) {
                num1 = num.pop();
                num2 = num.pop();
                num.push(num1 * num2);
            } else {
                num.push(Integer.parseInt(c));
            }
        }
        System.out.println(num.pop());
    } Scanner in = new Scanner(System.in); in new Scanner(System.in) String line = in.nextLine(); line in.nextLine() in.nextLine in Scanner opt = new Scanner(line); opt new Scanner(line) int num1 num1 num2; num2 Stack num = new Stack(); num new Stack() while (opt.hasNext()) {
            String c = opt.next();
            if (c.equals("+")) {
                num1 = num.pop();
                num2 = num.pop();
                num.push(num1 + num2);
            } else if (c.equals("-")) {
                num1 = num.pop();
                num2 = num.pop();
                num.push(num2 - num1);
            } else if (c.equals("*")) {
                num1 = num.pop();
                num2 = num.pop();
                num.push(num1 * num2);
            } else {
                num.push(Integer.parseInt(c));
            }
        } opt.hasNext() opt.hasNext opt {
            String c = opt.next();
            if (c.equals("+")) {
                num1 = num.pop();
                num2 = num.pop();
                num.push(num1 + num2);
            } else if (c.equals("-")) {
                num1 = num.pop();
                num2 = num.pop();
                num.push(num2 - num1);
            } else if (c.equals("*")) {
                num1 = num.pop();
                num2 = num.pop();
                num.push(num1 * num2);
            } else {
                num.push(Integer.parseInt(c));
            }
        } String c = opt.next(); c opt.next() opt.next opt if (c.equals("+")) {
                num1 = num.pop();
                num2 = num.pop();
                num.push(num1 + num2);
            } else if (c.equals("-")) {
                num1 = num.pop();
                num2 = num.pop();
                num.push(num2 - num1);
            } else if (c.equals("*")) {
                num1 = num.pop();
                num2 = num.pop();
                num.push(num1 * num2);
            } else {
                num.push(Integer.parseInt(c));
            } c.equals("+") c.equals c "+" {
                num1 = num.pop();
                num2 = num.pop();
                num.push(num1 + num2);
            } num1 = num.pop() num1 num.pop() num.pop num num2 = num.pop() num2 num.pop() num.pop num num.push(num1 + num2) num.push num num1 + num2 num1 num2 if (c.equals("-")) {
                num1 = num.pop();
                num2 = num.pop();
                num.push(num2 - num1);
            } else if (c.equals("*")) {
                num1 = num.pop();
                num2 = num.pop();
                num.push(num1 * num2);
            } else {
                num.push(Integer.parseInt(c));
            } c.equals("-") c.equals c "-" {
                num1 = num.pop();
                num2 = num.pop();
                num.push(num2 - num1);
            } num1 = num.pop() num1 num.pop() num.pop num num2 = num.pop() num2 num.pop() num.pop num num.push(num2 - num1) num.push num num2 - num1 num2 num1 if (c.equals("*")) {
                num1 = num.pop();
                num2 = num.pop();
                num.push(num1 * num2);
            } else {
                num.push(Integer.parseInt(c));
            } c.equals("*") c.equals c "*" {
                num1 = num.pop();
                num2 = num.pop();
                num.push(num1 * num2);
            } num1 = num.pop() num1 num.pop() num.pop num num2 = num.pop() num2 num.pop() num.pop num num.push(num1 * num2) num.push num num1 * num2 num1 num2 {
                num.push(Integer.parseInt(c));
            } num.push(Integer.parseInt(c)) num.push num Integer.parseInt(c) Integer.parseInt Integer c System.out.println(num.pop()) System.out.println System.out System System.out num.pop() num.pop num String[] args args class Stack {
    int top;
    int[] stack;

    public Stack() {
        this.top = 0;
        this.stack = new int[1000];
    }

    public void push(int num) {
        this.top++;
        this.stack[top] = num;
    }

    public int pop() {
        int num = this.stack[this.top];
        this.stack[this.top] = 0;
        this.top--;
        return num;
    }
} Stack int top; top int[] stack; stack public Stack() {
        this.top = 0;
        this.stack = new int[1000];
    } Stack {
        this.top = 0;
        this.stack = new int[1000];
    } this.top = 0 this.top this this.top 0 this.stack = new int[1000] this.stack this this.stack new int[1000] 1000 public void push(int num) {
        this.top++;
        this.stack[top] = num;
    } push {
        this.top++;
        this.stack[top] = num;
    } this.top++ this.top this this.top this.stack[top] = num this.stack[top] this.stack this this.stack top num int num num public int pop() {
        int num = this.stack[this.top];
        this.stack[this.top] = 0;
        this.top--;
        return num;
    } pop {
        int num = this.stack[this.top];
        this.stack[this.top] = 0;
        this.top--;
        return num;
    } int num = this.stack[this.top]; num this.stack[this.top] this.stack this this.stack this.top this this.top this.stack[this.top] = 0 this.stack[this.top] this.stack this this.stack this.top this this.top 0 this.top-- this.top this this.top return num; num public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String line = in.nextLine();
        Scanner opt = new Scanner(line);
        int num1, num2;
        Stack num = new Stack();
        while (opt.hasNext()) {
            String c = opt.next();
            if (c.equals("+")) {
                num1 = num.pop();
                num2 = num.pop();
                num.push(num1 + num2);
            } else if (c.equals("-")) {
                num1 = num.pop();
                num2 = num.pop();
                num.push(num2 - num1);
            } else if (c.equals("*")) {
                num1 = num.pop();
                num2 = num.pop();
                num.push(num1 * num2);
            } else {
                num.push(Integer.parseInt(c));
            }
        }
        System.out.println(num.pop());
    }
} public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String line = in.nextLine();
        Scanner opt = new Scanner(line);
        int num1, num2;
        Stack num = new Stack();
        while (opt.hasNext()) {
            String c = opt.next();
            if (c.equals("+")) {
                num1 = num.pop();
                num2 = num.pop();
                num.push(num1 + num2);
            } else if (c.equals("-")) {
                num1 = num.pop();
                num2 = num.pop();
                num.push(num2 - num1);
            } else if (c.equals("*")) {
                num1 = num.pop();
                num2 = num.pop();
                num.push(num1 * num2);
            } else {
                num.push(Integer.parseInt(c));
            }
        }
        System.out.println(num.pop());
    }
} Main
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String line = in.nextLine();
        Scanner opt = new Scanner(line);
        int num1, num2;
        Stack num = new Stack();
        while (opt.hasNext()) {
            String c = opt.next();
            if (c.equals("+")) {
                num1 = num.pop();
                num2 = num.pop();
                num.push(num1 + num2);
            } else if (c.equals("-")) {
                num1 = num.pop();
                num2 = num.pop();
                num.push(num2 - num1);
            } else if (c.equals("*")) {
                num1 = num.pop();
                num2 = num.pop();
                num.push(num1 * num2);
            } else {
                num.push(Integer.parseInt(c));
            }
        }
        System.out.println(num.pop());
    }
}

class Stack {
    int top;
    int[] stack;

    public Stack() {
        this.top = 0;
        this.stack = new int[1000];
    }

    public void push(int num) {
        this.top++;
        this.stack[top] = num;
    }

    public int pop() {
        int num = this.stack[this.top];
        this.stack[this.top] = 0;
        this.top--;
        return num;
    }
}
