import java.util.Scanner;

public class Main {

    public Main() {
    }

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

    private Scanner sc;

    private void solve() {
        sc = new Scanner(System.in);
        String f = sc.nextLine();
        String[] arr = f.split(" ");
        MyStack stack = new MyStack();
        for (String s : arr) {
            try {
                int n = Integer.parseInt(s);
                stack.push(n);
            } catch (Exception e) {
                int n1 = (int) stack.pop();
                int n2 = (int) stack.pop();
                stack.push(calc(n1, n2, s));
            }
        }
        System.out.println(stack.pop());
    }

    private int calc(int n1, int n2, String o) {
        if ("+".equals(o)) {
            return n2 + n1;
        } else if ("-".equals(o)) {
            return n2 - n1;
        } else {
            return n2 * n1;
        }
    }

}

class MyStack {
    int tail;
    Object[] arr;

    public MyStack() {
        this.tail = -1;
        arr = new Object[100];
    }

    public void push(Object o) {
        tail++;
        arr[tail] = o;
    }

    public Object pop() {
        if (isEmpty()) {
            return null;
        } else {
            Object r = arr[tail];
            arr[tail] = null;
            tail--;
            return r;
        }
    }

    public boolean isEmpty() {
        if (tail == -1) {
            return true;
        } else {
            return false;
        }
    }

} import java.util.Scanner; Scanner java.util public class Main {

    public Main() {
    }

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

    private Scanner sc;

    private void solve() {
        sc = new Scanner(System.in);
        String f = sc.nextLine();
        String[] arr = f.split(" ");
        MyStack stack = new MyStack();
        for (String s : arr) {
            try {
                int n = Integer.parseInt(s);
                stack.push(n);
            } catch (Exception e) {
                int n1 = (int) stack.pop();
                int n2 = (int) stack.pop();
                stack.push(calc(n1, n2, s));
            }
        }
        System.out.println(stack.pop());
    }

    private int calc(int n1, int n2, String o) {
        if ("+".equals(o)) {
            return n2 + n1;
        } else if ("-".equals(o)) {
            return n2 - n1;
        } else {
            return n2 * n1;
        }
    }

} Main private Scanner sc; sc public Main() {
    } Main {
    } 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);
        String f = sc.nextLine();
        String[] arr = f.split(" ");
        MyStack stack = new MyStack();
        for (String s : arr) {
            try {
                int n = Integer.parseInt(s);
                stack.push(n);
            } catch (Exception e) {
                int n1 = (int) stack.pop();
                int n2 = (int) stack.pop();
                stack.push(calc(n1, n2, s));
            }
        }
        System.out.println(stack.pop());
    } solve {
        sc = new Scanner(System.in);
        String f = sc.nextLine();
        String[] arr = f.split(" ");
        MyStack stack = new MyStack();
        for (String s : arr) {
            try {
                int n = Integer.parseInt(s);
                stack.push(n);
            } catch (Exception e) {
                int n1 = (int) stack.pop();
                int n2 = (int) stack.pop();
                stack.push(calc(n1, n2, s));
            }
        }
        System.out.println(stack.pop());
    } sc = new Scanner(System.in) sc new Scanner(System.in) String f = sc.nextLine(); f sc.nextLine() sc.nextLine sc String[] arr = f.split(" "); arr f.split(" ") f.split f " " MyStack stack = new MyStack(); stack new MyStack() for (String s : arr) {
            try {
                int n = Integer.parseInt(s);
                stack.push(n);
            } catch (Exception e) {
                int n1 = (int) stack.pop();
                int n2 = (int) stack.pop();
                stack.push(calc(n1, n2, s));
            }
        } String s arr {
            try {
                int n = Integer.parseInt(s);
                stack.push(n);
            } catch (Exception e) {
                int n1 = (int) stack.pop();
                int n2 = (int) stack.pop();
                stack.push(calc(n1, n2, s));
            }
        } {
            try {
                int n = Integer.parseInt(s);
                stack.push(n);
            } catch (Exception e) {
                int n1 = (int) stack.pop();
                int n2 = (int) stack.pop();
                stack.push(calc(n1, n2, s));
            }
        } try {
                int n = Integer.parseInt(s);
                stack.push(n);
            } catch (Exception e) {
                int n1 = (int) stack.pop();
                int n2 = (int) stack.pop();
                stack.push(calc(n1, n2, s));
            } catch (Exception e) {
                int n1 = (int) stack.pop();
                int n2 = (int) stack.pop();
                stack.push(calc(n1, n2, s));
            } Exception e {
                int n1 = (int) stack.pop();
                int n2 = (int) stack.pop();
                stack.push(calc(n1, n2, s));
            } int n1 = (int) stack.pop(); n1 (int) stack.pop() stack.pop stack int n2 = (int) stack.pop(); n2 (int) stack.pop() stack.pop stack stack.push(calc(n1, n2, s)) stack.push stack calc(n1, n2, s) calc n1 n2 s {
                int n = Integer.parseInt(s);
                stack.push(n);
            } int n = Integer.parseInt(s); n Integer.parseInt(s) Integer.parseInt Integer s stack.push(n) stack.push stack n System.out.println(stack.pop()) System.out.println System.out System System.out stack.pop() stack.pop stack private int calc(int n1, int n2, String o) {
        if ("+".equals(o)) {
            return n2 + n1;
        } else if ("-".equals(o)) {
            return n2 - n1;
        } else {
            return n2 * n1;
        }
    } calc {
        if ("+".equals(o)) {
            return n2 + n1;
        } else if ("-".equals(o)) {
            return n2 - n1;
        } else {
            return n2 * n1;
        }
    } if ("+".equals(o)) {
            return n2 + n1;
        } else if ("-".equals(o)) {
            return n2 - n1;
        } else {
            return n2 * n1;
        } "+".equals(o) "+".equals "+" o {
            return n2 + n1;
        } return n2 + n1; n2 + n1 n2 n1 if ("-".equals(o)) {
            return n2 - n1;
        } else {
            return n2 * n1;
        } "-".equals(o) "-".equals "-" o {
            return n2 - n1;
        } return n2 - n1; n2 - n1 n2 n1 {
            return n2 * n1;
        } return n2 * n1; n2 * n1 n2 n1 int n1 n1 int n2 n2 String o o class MyStack {
    int tail;
    Object[] arr;

    public MyStack() {
        this.tail = -1;
        arr = new Object[100];
    }

    public void push(Object o) {
        tail++;
        arr[tail] = o;
    }

    public Object pop() {
        if (isEmpty()) {
            return null;
        } else {
            Object r = arr[tail];
            arr[tail] = null;
            tail--;
            return r;
        }
    }

    public boolean isEmpty() {
        if (tail == -1) {
            return true;
        } else {
            return false;
        }
    }

} MyStack int tail; tail Object[] arr; arr public MyStack() {
        this.tail = -1;
        arr = new Object[100];
    } MyStack {
        this.tail = -1;
        arr = new Object[100];
    } this.tail = -1 this.tail this this.tail -1 1 arr = new Object[100] arr new Object[100] 100 public void push(Object o) {
        tail++;
        arr[tail] = o;
    } push {
        tail++;
        arr[tail] = o;
    } tail++ tail arr[tail] = o arr[tail] arr tail o Object o o public Object pop() {
        if (isEmpty()) {
            return null;
        } else {
            Object r = arr[tail];
            arr[tail] = null;
            tail--;
            return r;
        }
    } pop {
        if (isEmpty()) {
            return null;
        } else {
            Object r = arr[tail];
            arr[tail] = null;
            tail--;
            return r;
        }
    } if (isEmpty()) {
            return null;
        } else {
            Object r = arr[tail];
            arr[tail] = null;
            tail--;
            return r;
        } isEmpty() isEmpty {
            return null;
        } return null; null {
            Object r = arr[tail];
            arr[tail] = null;
            tail--;
            return r;
        } Object r = arr[tail]; r arr[tail] arr tail arr[tail] = null arr[tail] arr tail null tail-- tail return r; r public boolean isEmpty() {
        if (tail == -1) {
            return true;
        } else {
            return false;
        }
    } isEmpty {
        if (tail == -1) {
            return true;
        } else {
            return false;
        }
    } if (tail == -1) {
            return true;
        } else {
            return false;
        } tail == -1 tail -1 1 {
            return true;
        } return true; true {
            return false;
        } return false; false public class Main {

    public Main() {
    }

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

    private Scanner sc;

    private void solve() {
        sc = new Scanner(System.in);
        String f = sc.nextLine();
        String[] arr = f.split(" ");
        MyStack stack = new MyStack();
        for (String s : arr) {
            try {
                int n = Integer.parseInt(s);
                stack.push(n);
            } catch (Exception e) {
                int n1 = (int) stack.pop();
                int n2 = (int) stack.pop();
                stack.push(calc(n1, n2, s));
            }
        }
        System.out.println(stack.pop());
    }

    private int calc(int n1, int n2, String o) {
        if ("+".equals(o)) {
            return n2 + n1;
        } else if ("-".equals(o)) {
            return n2 - n1;
        } else {
            return n2 * n1;
        }
    }

} public class Main {

    public Main() {
    }

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

    private Scanner sc;

    private void solve() {
        sc = new Scanner(System.in);
        String f = sc.nextLine();
        String[] arr = f.split(" ");
        MyStack stack = new MyStack();
        for (String s : arr) {
            try {
                int n = Integer.parseInt(s);
                stack.push(n);
            } catch (Exception e) {
                int n1 = (int) stack.pop();
                int n2 = (int) stack.pop();
                stack.push(calc(n1, n2, s));
            }
        }
        System.out.println(stack.pop());
    }

    private int calc(int n1, int n2, String o) {
        if ("+".equals(o)) {
            return n2 + n1;
        } else if ("-".equals(o)) {
            return n2 - n1;
        } else {
            return n2 * n1;
        }
    }

} Main
import java.util.Scanner;

public class Main {

    public Main() {
    }

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

    private Scanner sc;

    private void solve() {
        sc = new Scanner(System.in);
        String f = sc.nextLine();
        String[] arr = f.split(" ");
        MyStack stack = new MyStack();
        for (String s : arr) {
            try {
                int n = Integer.parseInt(s);
                stack.push(n);
            } catch (Exception e) {
                int n1 = (int) stack.pop();
                int n2 = (int) stack.pop();
                stack.push(calc(n1, n2, s));
            }
        }
        System.out.println(stack.pop());
    }

    private int calc(int n1, int n2, String o) {
        if ("+".equals(o)) {
            return n2 + n1;
        } else if ("-".equals(o)) {
            return n2 - n1;
        } else {
            return n2 * n1;
        }
    }

}

class MyStack {
    int tail;
    Object[] arr;

    public MyStack() {
        this.tail = -1;
        arr = new Object[100];
    }

    public void push(Object o) {
        tail++;
        arr[tail] = o;
    }

    public Object pop() {
        if (isEmpty()) {
            return null;
        } else {
            Object r = arr[tail];
            arr[tail] = null;
            tail--;
            return r;
        }
    }

    public boolean isEmpty() {
        if (tail == -1) {
            return true;
        } else {
            return false;
        }
    }

}