EasyRating 1000
Turning to a Page
A book opens to page 1 on the right side. Each turn shows two more pages (2–3, 4–5, …). You can start from the front or the back. How few turns are needed to reach page p of an n-page book?
Input
Two integers n and p (1 ≤ p ≤ n ≤ 10⁵).
Output
One integer.
Sample 1
Input
6 2
Output
1
Sample 2
Input
5 4
Output
0
Output appears here