#include #define ll long long #define INIT std::ios::sync_with_stdio(false);std::cin.tie(0); #define FOR(i,a,b) for(int i=(a);i<(b);++i) #define REP(i,n) FOR(i,0,n) #define dump(x) cerr << #x << " = " << (x) << endl; #define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl; using namespace std; int main() { INIT; int a,b; cin >> a >> b; for (size_t c = b-a; c < 10^18; c+=b) { if((a+b) % c == 0 && (c+b) % a == 0 && (a+c) % b == 0){ //cout << c << endl; printf("%d", c); exit(0); } } //cout << "-1" << endl; printf("-1"); return 0; }