import java.util.*;

public class Main {
    
    public static void main(String[] args) {
        Main main = new Main();
        main.solv();
    }
    
    private void solv() {
        Scanner input = new Scanner(System.in);
        Stack<Long> st = new Stack<Long>();
        while (input.hasNext()) {
            String s = input.next();
            if ("+".equals(s)) {
                long y = Long.valueOf(st.pop());
                long x = Long.valueOf(st.pop());
                st.push(x + y);
            } else if ("-".equals(s)) {
                long y = Long.valueOf(st.pop());
                long x = Long.valueOf(st.pop());
                st.push(x - y);
            } else if ("*".equals(s)) {
                long y = Long.valueOf(st.pop());
                long x = Long.valueOf(st.pop());
                st.push(x * y);
            } else {
                st.push(Long.valueOf(s));
            }
        }
        System.out.println(st.pop());
    }
    
    private void print(Object[] xs) {
        StringBuilder sb = new StringBuilder();
        for (Object x : xs) sb.append(x.toString()).append(' ');
        System.out.println(sb.toString().trim());
    }
} import java.util.*; util.* java public class Main {
    
    public static void main(String[] args) {
        Main main = new Main();
        main.solv();
    }
    
    private void solv() {
        Scanner input = new Scanner(System.in);
        Stack<Long> st = new Stack<Long>();
        while (input.hasNext()) {
            String s = input.next();
            if ("+".equals(s)) {
                long y = Long.valueOf(st.pop());
                long x = Long.valueOf(st.pop());
                st.push(x + y);
            } else if ("-".equals(s)) {
                long y = Long.valueOf(st.pop());
                long x = Long.valueOf(st.pop());
                st.push(x - y);
            } else if ("*".equals(s)) {
                long y = Long.valueOf(st.pop());
                long x = Long.valueOf(st.pop());
                st.push(x * y);
            } else {
                st.push(Long.valueOf(s));
            }
        }
        System.out.println(st.pop());
    }
    
    private void print(Object[] xs) {
        StringBuilder sb = new StringBuilder();
        for (Object x : xs) sb.append(x.toString()).append(' ');
        System.out.println(sb.toString().trim());
    }
} Main public static void main(String[] args) {
        Main main = new Main();
        main.solv();
    } main {
        Main main = new Main();
        main.solv();
    } Main main = new Main(); main new Main() main.solv() main.solv main String[] args args private void solv() {
        Scanner input = new Scanner(System.in);
        Stack<Long> st = new Stack<Long>();
        while (input.hasNext()) {
            String s = input.next();
            if ("+".equals(s)) {
                long y = Long.valueOf(st.pop());
                long x = Long.valueOf(st.pop());
                st.push(x + y);
            } else if ("-".equals(s)) {
                long y = Long.valueOf(st.pop());
                long x = Long.valueOf(st.pop());
                st.push(x - y);
            } else if ("*".equals(s)) {
                long y = Long.valueOf(st.pop());
                long x = Long.valueOf(st.pop());
                st.push(x * y);
            } else {
                st.push(Long.valueOf(s));
            }
        }
        System.out.println(st.pop());
    } solv {
        Scanner input = new Scanner(System.in);
        Stack<Long> st = new Stack<Long>();
        while (input.hasNext()) {
            String s = input.next();
            if ("+".equals(s)) {
                long y = Long.valueOf(st.pop());
                long x = Long.valueOf(st.pop());
                st.push(x + y);
            } else if ("-".equals(s)) {
                long y = Long.valueOf(st.pop());
                long x = Long.valueOf(st.pop());
                st.push(x - y);
            } else if ("*".equals(s)) {
                long y = Long.valueOf(st.pop());
                long x = Long.valueOf(st.pop());
                st.push(x * y);
            } else {
                st.push(Long.valueOf(s));
            }
        }
        System.out.println(st.pop());
    } Scanner input = new Scanner(System.in); input new Scanner(System.in) Stack<Long> st = new Stack<Long>(); st new Stack<Long>() while (input.hasNext()) {
            String s = input.next();
            if ("+".equals(s)) {
                long y = Long.valueOf(st.pop());
                long x = Long.valueOf(st.pop());
                st.push(x + y);
            } else if ("-".equals(s)) {
                long y = Long.valueOf(st.pop());
                long x = Long.valueOf(st.pop());
                st.push(x - y);
            } else if ("*".equals(s)) {
                long y = Long.valueOf(st.pop());
                long x = Long.valueOf(st.pop());
                st.push(x * y);
            } else {
                st.push(Long.valueOf(s));
            }
        } input.hasNext() input.hasNext input {
            String s = input.next();
            if ("+".equals(s)) {
                long y = Long.valueOf(st.pop());
                long x = Long.valueOf(st.pop());
                st.push(x + y);
            } else if ("-".equals(s)) {
                long y = Long.valueOf(st.pop());
                long x = Long.valueOf(st.pop());
                st.push(x - y);
            } else if ("*".equals(s)) {
                long y = Long.valueOf(st.pop());
                long x = Long.valueOf(st.pop());
                st.push(x * y);
            } else {
                st.push(Long.valueOf(s));
            }
        } String s = input.next(); s input.next() input.next input if ("+".equals(s)) {
                long y = Long.valueOf(st.pop());
                long x = Long.valueOf(st.pop());
                st.push(x + y);
            } else if ("-".equals(s)) {
                long y = Long.valueOf(st.pop());
                long x = Long.valueOf(st.pop());
                st.push(x - y);
            } else if ("*".equals(s)) {
                long y = Long.valueOf(st.pop());
                long x = Long.valueOf(st.pop());
                st.push(x * y);
            } else {
                st.push(Long.valueOf(s));
            } "+".equals(s) "+".equals "+" s {
                long y = Long.valueOf(st.pop());
                long x = Long.valueOf(st.pop());
                st.push(x + y);
            } long y = Long.valueOf(st.pop()); y Long.valueOf(st.pop()) Long.valueOf Long st.pop() st.pop st long x = Long.valueOf(st.pop()); x Long.valueOf(st.pop()) Long.valueOf Long st.pop() st.pop st st.push(x + y) st.push st x + y x y if ("-".equals(s)) {
                long y = Long.valueOf(st.pop());
                long x = Long.valueOf(st.pop());
                st.push(x - y);
            } else if ("*".equals(s)) {
                long y = Long.valueOf(st.pop());
                long x = Long.valueOf(st.pop());
                st.push(x * y);
            } else {
                st.push(Long.valueOf(s));
            } "-".equals(s) "-".equals "-" s {
                long y = Long.valueOf(st.pop());
                long x = Long.valueOf(st.pop());
                st.push(x - y);
            } long y = Long.valueOf(st.pop()); y Long.valueOf(st.pop()) Long.valueOf Long st.pop() st.pop st long x = Long.valueOf(st.pop()); x Long.valueOf(st.pop()) Long.valueOf Long st.pop() st.pop st st.push(x - y) st.push st x - y x y if ("*".equals(s)) {
                long y = Long.valueOf(st.pop());
                long x = Long.valueOf(st.pop());
                st.push(x * y);
            } else {
                st.push(Long.valueOf(s));
            } "*".equals(s) "*".equals "*" s {
                long y = Long.valueOf(st.pop());
                long x = Long.valueOf(st.pop());
                st.push(x * y);
            } long y = Long.valueOf(st.pop()); y Long.valueOf(st.pop()) Long.valueOf Long st.pop() st.pop st long x = Long.valueOf(st.pop()); x Long.valueOf(st.pop()) Long.valueOf Long st.pop() st.pop st st.push(x * y) st.push st x * y x y {
                st.push(Long.valueOf(s));
            } st.push(Long.valueOf(s)) st.push st Long.valueOf(s) Long.valueOf Long s System.out.println(st.pop()) System.out.println System.out System System.out st.pop() st.pop st private void print(Object[] xs) {
        StringBuilder sb = new StringBuilder();
        for (Object x : xs) sb.append(x.toString()).append(' ');
        System.out.println(sb.toString().trim());
    } print {
        StringBuilder sb = new StringBuilder();
        for (Object x : xs) sb.append(x.toString()).append(' ');
        System.out.println(sb.toString().trim());
    } StringBuilder sb = new StringBuilder(); sb new StringBuilder() for (Object x : xs) sb.append(x.toString()).append(' '); Object x xs sb.append(x.toString()).append(' '); sb.append(x.toString()).append(' ') sb.append(x.toString()).append sb.append(x.toString()) sb.append sb x.toString() x.toString x ' ' System.out.println(sb.toString().trim()) System.out.println System.out System System.out sb.toString().trim() sb.toString().trim sb.toString() sb.toString sb Object[] xs xs public class Main {
    
    public static void main(String[] args) {
        Main main = new Main();
        main.solv();
    }
    
    private void solv() {
        Scanner input = new Scanner(System.in);
        Stack<Long> st = new Stack<Long>();
        while (input.hasNext()) {
            String s = input.next();
            if ("+".equals(s)) {
                long y = Long.valueOf(st.pop());
                long x = Long.valueOf(st.pop());
                st.push(x + y);
            } else if ("-".equals(s)) {
                long y = Long.valueOf(st.pop());
                long x = Long.valueOf(st.pop());
                st.push(x - y);
            } else if ("*".equals(s)) {
                long y = Long.valueOf(st.pop());
                long x = Long.valueOf(st.pop());
                st.push(x * y);
            } else {
                st.push(Long.valueOf(s));
            }
        }
        System.out.println(st.pop());
    }
    
    private void print(Object[] xs) {
        StringBuilder sb = new StringBuilder();
        for (Object x : xs) sb.append(x.toString()).append(' ');
        System.out.println(sb.toString().trim());
    }
} public class Main {
    
    public static void main(String[] args) {
        Main main = new Main();
        main.solv();
    }
    
    private void solv() {
        Scanner input = new Scanner(System.in);
        Stack<Long> st = new Stack<Long>();
        while (input.hasNext()) {
            String s = input.next();
            if ("+".equals(s)) {
                long y = Long.valueOf(st.pop());
                long x = Long.valueOf(st.pop());
                st.push(x + y);
            } else if ("-".equals(s)) {
                long y = Long.valueOf(st.pop());
                long x = Long.valueOf(st.pop());
                st.push(x - y);
            } else if ("*".equals(s)) {
                long y = Long.valueOf(st.pop());
                long x = Long.valueOf(st.pop());
                st.push(x * y);
            } else {
                st.push(Long.valueOf(s));
            }
        }
        System.out.println(st.pop());
    }
    
    private void print(Object[] xs) {
        StringBuilder sb = new StringBuilder();
        for (Object x : xs) sb.append(x.toString()).append(' ');
        System.out.println(sb.toString().trim());
    }
} Main
import java.util.*;

public class Main {
    
    public static void main(String[] args) {
        Main main = new Main();
        main.solv();
    }
    
    private void solv() {
        Scanner input = new Scanner(System.in);
        Stack<Long> st = new Stack<Long>();
        while (input.hasNext()) {
            String s = input.next();
            if ("+".equals(s)) {
                long y = Long.valueOf(st.pop());
                long x = Long.valueOf(st.pop());
                st.push(x + y);
            } else if ("-".equals(s)) {
                long y = Long.valueOf(st.pop());
                long x = Long.valueOf(st.pop());
                st.push(x - y);
            } else if ("*".equals(s)) {
                long y = Long.valueOf(st.pop());
                long x = Long.valueOf(st.pop());
                st.push(x * y);
            } else {
                st.push(Long.valueOf(s));
            }
        }
        System.out.println(st.pop());
    }
    
    private void print(Object[] xs) {
        StringBuilder sb = new StringBuilder();
        for (Object x : xs) sb.append(x.toString()).append(' ');
        System.out.println(sb.toString().trim());
    }
}