Platform#12319

Platform

1 second
256 megabytes
Medium

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:

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 .

Input

The first line contains two integers and (1 \le n \le 10^{18}, 1 \le k \le n).

Output

Output a single integer — the answer to the problem.

Examples

Example 1

Loading
Loading

Example 2

Loading
Loading

Note

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 .

Scoring

  1. Subtask ( points): (n \le 5000)

  2. Subtask ( points): ( is odd)

  3. Subtask ( points): No additional constraints