#include #include #include #include #include #include #include #include #include #define ALL(obj) (obj).begin(),(obj).end() #define RALL(obj) (obj).rbegin(),(obj).rend() #define P pair #define MOD 1000000007 #define INF 2147483647 #define NINF (-2147483647-1) #define LLINF 9223372036854775807 using ll = long long; using namespace std; int main() { int A, B; cin >> A >> B; int a = min(A, B), b = max(A, B); int C = b - a; if ((C + b) % a == 0 && (a + b) % C == 0) { cout << C << endl; } else { C = a + b; if ((C + a) % b == 0 && (C + b) % a == 0) { cout << C << endl; } else { cout << -1 << endl; } } getchar(); getchar(); return 0; }