#P2818. Finding the Correct Script Box

    ID: 16079 Type: Default 1000ms 256MiB

Finding the Correct Script Box

Finding the Correct Script Box

An angel is tasked with finding her speech manuscript from among n boxes arranged in a circle with labels from 1 to n in a clockwise direction. Although all angels initially stand by the nth box, each angel holds a number m which denotes that her manuscript is in the box that is the m-th in order starting from box 1 (in clockwise order).

For example, if there are 7 boxes and the angel's number is 9, then her manuscript is in box 2 because

result=((91)mod7)+1=2.\text{result} = ((9 - 1) \bmod 7) + 1 = 2.

Help the angel determine the correct box number where her manuscript is located. Use the formula below:

result=((m1)modn)+1.\text{result} = ((m - 1) \bmod n) + 1.

inputFormat

The input consists of two space-separated integers: n (the number of boxes) and m (the number in the angel's hand).

outputFormat

Output the box number where the angel's manuscript is located.

sample

7 9
2