#include "bits/stdc++.h" using namespace std; void solve() { long a, b; cin >> a >> b; if (a < b) swap(a, b); for (long i = 1; i * i <= a + b; i++) { if ((a-b)%i) continue; long c = (a - b) / i; if ((a + c) % b == 0 && (a + b) % c == 0 && (b + c) % a == 0) { cout << c << endl; return; } } cout << -1 << endl; } int main() { solve(); //cout << "yui(*-v・)yui" << endl; return 0; }