PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#GL0000083. Neko tối ưu BCNN sau khi cộng (Neko does Maths)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Neko tối ưu BCNN sau khi cộng (Neko does Maths)

Neko does Maths

Source: Codeforces

Version: Phuoc Hung OJ Extended

Problem Statement

Neko has positive integers aa and bb. Choose a nonnegative integer kk to add to both numbers, minimizing lcm⁡(a+k,b+k)\operatorname{lcm}(a+k,b+k). If several kk values yield the same minimum LCM, choose the smallest such kk.

Input

One line containing integers aa and bb.

Output

Print the smallest nonnegative kk yielding the minimum LCM.

Subtasks

  • Subtask 1 (20 points): 1≤a,b≤1001\le a,b\le100.

  • Subtask 2 (30 points): 1≤a,b≤1061\le a,b\le10^6.

  • Subtask 3 (50 points): 1≤a,b≤1091\le a,b\le10^9.

Examples

Input

6 10

Output

2

Explanation

For k=2k=2 the values become 88 and 1212 with LCM 2424. For k=0k=0 the LCM is 3030, while for k=1k=1 it is 7777. No kk gives an LCM smaller than 2424.