#include #define rep(i,a,b) for(int i=(int)(a);i<(int)(b);++i) #define rrep(i,a,b) for(int i=(int)(a);i>=(int)(b);--i) #define fore(i,a) for(auto &i:a) #define all(a) (a).begin(),(a).end() using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); } using ll = long long; constexpr int inf = INT_MAX / 2; constexpr ll infl = 1LL << 60; templatevoid YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; } templatevoid Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; } templatevoid POSS(T condition){ if(condition) cout << "POSSIBLE" << endl; else cout << "IMPOSSIBLE" << endl; } templatevoid Poss(T condition){ if(condition) cout << "Possible" << endl; else cout << "Impossible" << endl; } templatebool chmax(T &a, const T &b) { if (abool chmin(T &a, const T &b) { if (bT gcd(T a, T b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }} templateT lcm(T a, T b){ return a / gcd(a, b) * b; } ll A, B; ll AB; bool IsOk(ll c) { if (AB % c != 0) return false; if (A == c || B == c) return false; if ((A + c) % B != 0 || (B + c) % A != 0) return false; return true; } void _main() { cin >> A >> B; AB = A + B; ll ans = -1; for (ll i=1; i*i<=AB; i++) { if (IsOk(i)) { ans = i; break; } } cout << ans << endl; }