The train consists of cars, and there are exactly possible waiting spots on the platform, numbered from to from left to right (conditionally opposite the corresponding cars).
You know that your ticket is for car number , but you do not know from which side the numbering of the cars starts: either from left to right or from right to left (both options are possible).
When the train stops, you choose a spot where you will wait.
After the train arrives, you need to get to car as quickly as possible.
When the car arrives, the following options will be possible:
If the numbering is from left to right, then car will be opposite spot .
If the numbering is from right to left, then car will be opposite spot (n-k+1).
We consider that the time to run is proportional to the distance between the waiting spots, that is, it equals the absolute difference of their numbers.
Thus, if you are waiting at spot , then in the first case you will spend |p-k|, and in the second case — |p-(n-k+1)|.
We will call a possible movement the maximum movement from the first and second cases.
You need to find the minimum value of the possible movement among all possible values of .
The first line contains two integers and (1 \le n \le 10^{18}, 1 \le k \le n).
Output a single integer — the answer to the problem.
Example 1
Example 2
For the first test:
If we stand at the first waiting position, then the possible movement will be equal to max(|1 - 12|, |1 - (17-12+1)|) .
By checking all values of , the answer is achieved at .
Subtask ( points): (n \le 5000)
Subtask ( points): ( is odd)
Subtask ( points): No additional constraints