public static int countNumberOfCombinations(int n, int k) {
        if (n < 0 || k < 0 || k > n) {
            return 0;
        }
        
        long numerator = 1;
        
        for (int i = n; i > n - k; i--) {
            numerator *= i;        
        }
        
        long denominator = 1;
        for (int i = 1; i <= k; i++) {
            denominator *= i;
        }
        return (int) (numerator / denominator);
    }