#P2818. 天使的起誓
天使的起誓
Description
Tenshi is very lucky to be chosen as the angel who holds the Key of Wisdom. Before officially taking office, she must take an oath like the other newly elected angels.
During the oath ceremony, each angel states her mission, and their speech scripts are placed in treasure boxes arranged in a circle. These boxes are numbered clockwise as .
At the beginning, the angels stand next to the box numbered . Each of them holds a number that indicates the box containing her script is the -th one clockwise starting from box . For example: there are boxes, and if the number in Tenshi’s hand is , then the box containing her script is . Now the angels start to search for their scripts according to the numbers they hold; whoever finds it first will speak first.
Tenshi finds hers immediately and goes on stage first: “I will lead everyone to open the gate to NOI ...” After Tenshi finishes her oath, other angels go on stage one after another. However, one angel cannot find her script for a long time. It turns out that the number in her hand is very large, and after circling for a long time she still cannot find the box she wants.
Please help this angel find the index of the box she is looking for.
Input Format
The first line contains a positive integer , and the second line contains a positive integer .
Output Format
Output a single line: the index of the box the angel is looking for.
7
9
2
11
108
9
Hint
For 100% of the testdata, , .
Translated by ChatGPT 5
京公网安备 11011102002149号