import java.util.List;
import java.util.ArrayList;

import java.util.Scanner;

public class Main {
    private static Scanner sc = new Scanner(System.in);
    public static void main(String[] args) {
        Stack<Integer> stack = new Stack<>();
        while (sc.hasNext()) {
            String s = sc.next();
            if (isOperand(s)) {
                int a = stack.pop();
                int b = stack.pop();
                switch(s) {
                    case "+":
                        stack.push(a+b);
                        break;
                    case "-":
                        stack.push(b-a);
                        break;
                    case "*":
                        stack.push(a*b);
                        break;
                }
            } else {
                stack.push(Integer.parseInt(s));
            }
        }
        
        System.out.println(stack.pop());
    }
    
    static boolean isNumber(String s) {
        try {
            Integer.parseInt(s);
            return true;
        } catch (Exception e) {
            return false;
        }
    }
    
    static boolean isOperand(String s) {
        return s.equals("+") || s.equals("-") || s.equals("*");
    }
}

class Stack<T> {
    private List<T> list;
    
    public Stack() {
        list = new ArrayList<>();
    }
    
    public void push(T t) {
        list.add(t);
    }
    
    public T pop() {
        T t = list.get(list.size()-1);
        list.remove(list.size()-1);
        return t;
    }
    
    public boolean isEmpty() {
        return list.isEmpty();
    }
} import java.util.List; List java.util import java.util.ArrayList; ArrayList java.util import java.util.Scanner; Scanner java.util public class Main {
    private static Scanner sc = new Scanner(System.in);
    public static void main(String[] args) {
        Stack<Integer> stack = new Stack<>();
        while (sc.hasNext()) {
            String s = sc.next();
            if (isOperand(s)) {
                int a = stack.pop();
                int b = stack.pop();
                switch(s) {
                    case "+":
                        stack.push(a+b);
                        break;
                    case "-":
                        stack.push(b-a);
                        break;
                    case "*":
                        stack.push(a*b);
                        break;
                }
            } else {
                stack.push(Integer.parseInt(s));
            }
        }
        
        System.out.println(stack.pop());
    }
    
    static boolean isNumber(String s) {
        try {
            Integer.parseInt(s);
            return true;
        } catch (Exception e) {
            return false;
        }
    }
    
    static boolean isOperand(String s) {
        return s.equals("+") || s.equals("-") || s.equals("*");
    }
} Main private static Scanner sc = new Scanner(System.in); sc new Scanner(System.in) public static void main(String[] args) {
        Stack<Integer> stack = new Stack<>();
        while (sc.hasNext()) {
            String s = sc.next();
            if (isOperand(s)) {
                int a = stack.pop();
                int b = stack.pop();
                switch(s) {
                    case "+":
                        stack.push(a+b);
                        break;
                    case "-":
                        stack.push(b-a);
                        break;
                    case "*":
                        stack.push(a*b);
                        break;
                }
            } else {
                stack.push(Integer.parseInt(s));
            }
        }
        
        System.out.println(stack.pop());
    } main {
        Stack<Integer> stack = new Stack<>();
        while (sc.hasNext()) {
            String s = sc.next();
            if (isOperand(s)) {
                int a = stack.pop();
                int b = stack.pop();
                switch(s) {
                    case "+":
                        stack.push(a+b);
                        break;
                    case "-":
                        stack.push(b-a);
                        break;
                    case "*":
                        stack.push(a*b);
                        break;
                }
            } else {
                stack.push(Integer.parseInt(s));
            }
        }
        
        System.out.println(stack.pop());
    } Stack<Integer> stack = new Stack<>(); stack new Stack<>() while (sc.hasNext()) {
            String s = sc.next();
            if (isOperand(s)) {
                int a = stack.pop();
                int b = stack.pop();
                switch(s) {
                    case "+":
                        stack.push(a+b);
                        break;
                    case "-":
                        stack.push(b-a);
                        break;
                    case "*":
                        stack.push(a*b);
                        break;
                }
            } else {
                stack.push(Integer.parseInt(s));
            }
        } sc.hasNext() sc.hasNext sc {
            String s = sc.next();
            if (isOperand(s)) {
                int a = stack.pop();
                int b = stack.pop();
                switch(s) {
                    case "+":
                        stack.push(a+b);
                        break;
                    case "-":
                        stack.push(b-a);
                        break;
                    case "*":
                        stack.push(a*b);
                        break;
                }
            } else {
                stack.push(Integer.parseInt(s));
            }
        } String s = sc.next(); s sc.next() sc.next sc if (isOperand(s)) {
                int a = stack.pop();
                int b = stack.pop();
                switch(s) {
                    case "+":
                        stack.push(a+b);
                        break;
                    case "-":
                        stack.push(b-a);
                        break;
                    case "*":
                        stack.push(a*b);
                        break;
                }
            } else {
                stack.push(Integer.parseInt(s));
            } isOperand(s) isOperand s {
                int a = stack.pop();
                int b = stack.pop();
                switch(s) {
                    case "+":
                        stack.push(a+b);
                        break;
                    case "-":
                        stack.push(b-a);
                        break;
                    case "*":
                        stack.push(a*b);
                        break;
                }
            } int a = stack.pop(); a stack.pop() stack.pop stack int b = stack.pop(); b stack.pop() stack.pop stack switch(s) {
                    case "+":
                        stack.push(a+b);
                        break;
                    case "-":
                        stack.push(b-a);
                        break;
                    case "*":
                        stack.push(a*b);
                        break;
                } s case "+": "+" case "+": stack.push(a+b) stack.push stack a+b a b break; case "-": "-" case "-": stack.push(b-a) stack.push stack b-a b a break; case "*": "*" case "*": stack.push(a*b) stack.push stack a*b a b break; {
                stack.push(Integer.parseInt(s));
            } stack.push(Integer.parseInt(s)) stack.push stack Integer.parseInt(s) Integer.parseInt Integer s System.out.println(stack.pop()) System.out.println System.out System System.out stack.pop() stack.pop stack String[] args args static boolean isNumber(String s) {
        try {
            Integer.parseInt(s);
            return true;
        } catch (Exception e) {
            return false;
        }
    } isNumber {
        try {
            Integer.parseInt(s);
            return true;
        } catch (Exception e) {
            return false;
        }
    } try {
            Integer.parseInt(s);
            return true;
        } catch (Exception e) {
            return false;
        } catch (Exception e) {
            return false;
        } Exception e {
            return false;
        } return false; false {
            Integer.parseInt(s);
            return true;
        } Integer.parseInt(s) Integer.parseInt Integer s return true; true String s s static boolean isOperand(String s) {
        return s.equals("+") || s.equals("-") || s.equals("*");
    } isOperand {
        return s.equals("+") || s.equals("-") || s.equals("*");
    } return s.equals("+") || s.equals("-") || s.equals("*"); s.equals("+") || s.equals("-") || s.equals("*") s.equals("+") || s.equals("-") || s.equals("*") s.equals("+") s.equals s "+" s.equals("-") s.equals s "-" s.equals("*") s.equals s "*" String s s class Stack<T> {
    private List<T> list;
    
    public Stack() {
        list = new ArrayList<>();
    }
    
    public void push(T t) {
        list.add(t);
    }
    
    public T pop() {
        T t = list.get(list.size()-1);
        list.remove(list.size()-1);
        return t;
    }
    
    public boolean isEmpty() {
        return list.isEmpty();
    }
} Stack private List<T> list; list public Stack() {
        list = new ArrayList<>();
    } Stack {
        list = new ArrayList<>();
    } list = new ArrayList<>() list new ArrayList<>() public void push(T t) {
        list.add(t);
    } push {
        list.add(t);
    } list.add(t) list.add list t T t t public T pop() {
        T t = list.get(list.size()-1);
        list.remove(list.size()-1);
        return t;
    } pop {
        T t = list.get(list.size()-1);
        list.remove(list.size()-1);
        return t;
    } T t = list.get(list.size()-1); t list.get(list.size()-1) list.get list list.size()-1 list.size() list.size list 1 list.remove(list.size()-1) list.remove list list.size()-1 list.size() list.size list 1 return t; t public boolean isEmpty() {
        return list.isEmpty();
    } isEmpty {
        return list.isEmpty();
    } return list.isEmpty(); list.isEmpty() list.isEmpty list public class Main {
    private static Scanner sc = new Scanner(System.in);
    public static void main(String[] args) {
        Stack<Integer> stack = new Stack<>();
        while (sc.hasNext()) {
            String s = sc.next();
            if (isOperand(s)) {
                int a = stack.pop();
                int b = stack.pop();
                switch(s) {
                    case "+":
                        stack.push(a+b);
                        break;
                    case "-":
                        stack.push(b-a);
                        break;
                    case "*":
                        stack.push(a*b);
                        break;
                }
            } else {
                stack.push(Integer.parseInt(s));
            }
        }
        
        System.out.println(stack.pop());
    }
    
    static boolean isNumber(String s) {
        try {
            Integer.parseInt(s);
            return true;
        } catch (Exception e) {
            return false;
        }
    }
    
    static boolean isOperand(String s) {
        return s.equals("+") || s.equals("-") || s.equals("*");
    }
} public class Main {
    private static Scanner sc = new Scanner(System.in);
    public static void main(String[] args) {
        Stack<Integer> stack = new Stack<>();
        while (sc.hasNext()) {
            String s = sc.next();
            if (isOperand(s)) {
                int a = stack.pop();
                int b = stack.pop();
                switch(s) {
                    case "+":
                        stack.push(a+b);
                        break;
                    case "-":
                        stack.push(b-a);
                        break;
                    case "*":
                        stack.push(a*b);
                        break;
                }
            } else {
                stack.push(Integer.parseInt(s));
            }
        }
        
        System.out.println(stack.pop());
    }
    
    static boolean isNumber(String s) {
        try {
            Integer.parseInt(s);
            return true;
        } catch (Exception e) {
            return false;
        }
    }
    
    static boolean isOperand(String s) {
        return s.equals("+") || s.equals("-") || s.equals("*");
    }
} Main
import java.util.List;
import java.util.ArrayList;

import java.util.Scanner;

public class Main {
    private static Scanner sc = new Scanner(System.in);
    public static void main(String[] args) {
        Stack<Integer> stack = new Stack<>();
        while (sc.hasNext()) {
            String s = sc.next();
            if (isOperand(s)) {
                int a = stack.pop();
                int b = stack.pop();
                switch(s) {
                    case "+":
                        stack.push(a+b);
                        break;
                    case "-":
                        stack.push(b-a);
                        break;
                    case "*":
                        stack.push(a*b);
                        break;
                }
            } else {
                stack.push(Integer.parseInt(s));
            }
        }
        
        System.out.println(stack.pop());
    }
    
    static boolean isNumber(String s) {
        try {
            Integer.parseInt(s);
            return true;
        } catch (Exception e) {
            return false;
        }
    }
    
    static boolean isOperand(String s) {
        return s.equals("+") || s.equals("-") || s.equals("*");
    }
}

class Stack<T> {
    private List<T> list;
    
    public Stack() {
        list = new ArrayList<>();
    }
    
    public void push(T t) {
        list.add(t);
    }
    
    public T pop() {
        T t = list.get(list.size()-1);
        list.remove(list.size()-1);
        return t;
    }
    
    public boolean isEmpty() {
        return list.isEmpty();
    }
}