Count Numbers with Set Bit K
Count how many numbers from 1 to N have the Kth bit set.
Input format
A single line with N (1 ≤ N ≤ 10^5) and K (0-based bit position).
Output format
Print how many integers from 1 to N have the Kth bit set.
Constraints
- Values fit in a 64-bit signed integer
- Trailing whitespace and a trailing newline are ignored by the judge
Read from stdin, write to stdout. Sample cases below show the exact format.
Sample cases
Example 1
Input
10 1Expected output
5Example 2
Input
8 3Expected output
1