Problem D. Discarding numbers

Author:A. Verkholat   Time limit:1 sec
Input file:Standard input   Memory limit:256 Mb
Output file:Standard output  

Statement

Vasya wrote down all the numbers from 1 to N in a row.

He performs the following algorithm until there are no more numbers.

1) Discards the number from the beginning of the list.

2) Discards the number from the end of the list.

3) Reverses the order of the remaining numbers.

4) Goes to the first instruction.

What number will Vasya discard on the K-th step?

Input format

First line contains 2 integers: N and K.

Output format

A single integer representing K-th discarded number.

Constraints

1 ≤ N ≤ 109

1 ≤ K ≤ N

Notes on samples

Initial list: 1 2 3 4 5 6 7 8 9 10.

Vasya discards the first number: 2 3 4 5 6 7 8 9 10.

Discards from the end: 2 3 4 5 6 7 8 9.

Reverses the list: 9 8 7 6 5 4 3 2.

Discards the first number: 8 7 6 5 4 3 2.

Discards from the end: 8 7 6 5 4 3.

Reverses the list: 3 4 5 6 7 8.

The fifth discarded number was 3, which is the answer.

Sample tests

No. Standard input Standard output
1
10 5
3

0.072s 0.020s 13