#include #include #define fi first #define se second #define pb(x) push_back(x) #define sqr(x) ((x)*(x)) #define sz(x) (int)x.size() #define all(x) (x).begin(),(x).end() #define cs(x) printf("Case %d: ", x) #define lcm(x, y) (x * y) / (__gcd(x, y)) using namespace std; template inline void umax(T &x,T y) {if (y > x) x = y;} template inline void umin(T &x,T y) {if (y < x) x = y;} typedef long long ll; typedef pair pii; const int N = 2e5 + 5, B = 0x7fffffff; int a, b, mi = B, ans; int main(){ cin >> a >> b; for (int i = 1; i <= 1e6; i++){ ll pq = lcm(a + i, b + i); if (pq < mi) mi = pq, ans = i; } cout << ans; return !1; }