Numbers with K set bits

Count the integers from 0 to N − 1 whose binary form has exactly K ones.

Reported in: Deloitte (memory-based)

Input

One line: N and K.

Output

The count.

Constraints

1 ≤ N ≤ 10^6; 0 ≤ K ≤ 20.

Example 1

Input:
7 2

Output:
3

Example 2

Input:
16 1

Output:
4

Hint: For small N, count the ones in each number with bin(x).count("1") or a bit loop.

All coding practice