#include <bits/stdc++.h>   using namespace std;   vector<int> dvsr;   void get(long long n) {     for (int i = 1; i <= sqrt(n); i++) {       if (n % i == 0) {         dvsr.push_back(i);         if (i != n / i) dvsr.push_back(n / i);       }     }   }   int main() {     std::ios::sync_with_stdio(false);     cin.tie(NULL);     long long a, b;     cin >> a >> b;     if (a == b) {       cout << 0;       return 0;     }     if (a > b) swap(a, b);     long long df = b - a;     get(df);     set<pair<long long, long long> > s;     for (auto it : dvsr) {       if (a % it == 0 and b % it == 0) {         s.insert({(a * b) / it, 0});       } else {         long long dif = it * (b / it + 1) - b;         long long x = a + dif, y = b + dif;         s.insert({(x * y) / it, dif});       }     }     long long ans = b;     auto i1 = s.begin();     cout << i1->second;   }   