#t251. 天使的起誓(yubikili)
天使的起誓(yubikili)
The Angel's Oath
Problem Background
TENSHI was very lucky to be chosen as the angel in charge of the Key of Wisdom. Before officially taking office, she, like the other newly elected angels, must take an oath. In the ceremony, each angel states her own mission; their speeches are placed in treasure boxes arranged in a circle. These boxes are numbered clockwise .
At the beginning the angels stand next to the box numbered . Each holds a number representing, counting clockwise from box , which box her speech is in. For example, with boxes, if TENSHI's number is , then her speech is in the nd box. Now the angels start looking for their speeches according to their numbers; whoever finds hers first may speak first. TENSHI found hers at once and was the first to step up: "I will lead everyone to open the door of NOI…" After TENSHI's oath, other angels came up one after another. But one angel searched for a long time without finding her speech — her number was so large that she went around many times and still could not find the box she wanted.
Problem Description
Please help this angel find the number of the box she is looking for.
Input Format
The first and second lines each contain a positive integer and , where and satisfy and .
Output Format
The number of the box she is looking for.
Sample Input
Sample Input 1
7
9
Sample Input 2
11
108
Sample Output
Sample Output 1
2
Sample Output 2
9
Constraints
1s, 1024KiB for each test case.