#P2907. Farmer John's Cow Splitting

    ID: 16165 Type: Default 1000ms 256MiB

Farmer John's Cow Splitting

Farmer John's Cow Splitting

Farmer John's cows have taken an interest in exploring the territory around the farm. Initially, all N (1 \leq N \leq 10^9) cows travel as one big group. Whenever a group encounters a fork in the road, they try to split into two nonempty groups if they can do so such that the sizes of the groups differ by exactly K (1 \leq K \leq 1000). In particular, if a group of size \( m \) can be split into two groups of sizes \( a \) and \( b \) satisfying:

[ \begin{cases} a+b = m, \ a-b = K, \quad (a > b > 0), \end{cases} ]

then the group splits into \( a=\frac{m+K}{2} \) and \( b=\frac{m-K}{2} \). Otherwise, the group stops splitting and starts grazing peacefully.

Assuming that there will always be new forks in the road, compute the final number of peacefully grazing groups.

inputFormat

The input consists of a single line containing two integers: N and K.

outputFormat

Output a single integer representing the final number of groups.

sample

16 2
2