class Factorial {
    static int fact(int n) throws FactorialException {
        if (n < 0) throw new FactorialException("Invalid input.");
        else if (n == 0) return 1;
        else return n * fact(n - 1);
    }
    public static void main(String[] args) {
        try {
            System.out.println(fact(Integer.parseInt(args[0])));
        } catch (FactorialException e) {
            System.err.println(e.getMessage());
        } catch (IndexOutOfBoundsException e) {
            System.err.println("No input provided.");
        } catch (NumberFormatException e) {
            System.err.println("Invalid input.");
        }          
    }
}

