Problem C: 同余方程

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

Description

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

Input

一行,包含两个整数a,b,用一个空格隔开。

Output


一个整数x0,即最小正整数解。输入数据保证一定有解。

Sample Input Copy

3 10

Sample Output Copy

7

HINT

  • 对于40%的数据,2≤b≤103
  • 对于60%的数据,2≤b≤5×107
  • 对于100%的数据,2≤a,b≤2×109