Pass the Parcel

SEC Inter University Juni...
Limits 1s, 512 MB

There are $n$ people in a room. They want to play a game called “pass the parcel”.

The people are numbered from $0$ to $n-1$.

If $i^{\text{th}}$ person has the parcel in $t^{\text{th}}$ second, he gives it to the $j^{\text{th}}$ person in $(t+1)^{\text{th}}$ second.

where $j = \left\{\begin{matrix} i+1 \text{; if } 0\le i \le n-2\\0 \text{; otherwise }\\\end{matrix}\right.$

For example, At $0^{\text{th}}$ second, the $0^{\text{th}}$ person has the parcel. The next second ($1^{\text{st}})$, he gives the parcel to the $1^{\text{st}}$ person. And the next second, he gives it to $2^{\text{nd}}$ person and so on. And when the $(n-1)^{\text{th}}$ has the parcel he gives it to the $0^{\text{th}}$ person in next second. And again $0^{\text{th}}$ person gives it to $1^{\text{st}}$ person in next second. It will continue this way.

You will be given an integer $k$. You have to answer who will have the parcel in the $k^{\text{th}}$ second.

Input

The first (and the only) input line contains two integers $n(1\le n \le 1000)$ and $k(0\le k\le 1000)$— number of people, and time respectively.

Output

Print the number of the person, who will have the parcel in the $k^{\text{th}}$ second, in a single line.

Samples

InputOutput
2 2

0

InputOutput
3 5

2