4053: 【12NOIP提高组】同余方程

Memory Limit:128 MB Time Limit:1.000 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

求关于 $x$ 的同余方程 $ax ≡ 1 (bmod b)$的最小正整数解。

Input

输入只有一行,包含两个正整数 $a, b$,用一个空格隔开。

Output

输出只有一行,包含一个正整数 $x_0$,即最小正整数解。输入数据保证一定有解。

Sample Input Copy

3 10

Sample Output Copy

7

Source/Category