Count Permutations with Max Gap Constraint