38985 - 因子问题 202312 202009

通过次数

6

提交次数

11

Time Limit : 1 秒
Memory Limit : 128 MB

任给两个正整数N、M,求一个最小的正整数a,使得a和(M-a)都是N的因子。

Input

包括两个整数N、M。N不超过1,000,000。

Output

输出一个整数a,表示结果。如果某个案例中满足条件的正整数不存在,则在对应行输出-1

Examples

Input

35 10

Output

5

Source

枚举