#include using namespace std; int main() { int A, B; int C = -1; cin >> A >> B; for(int n = 1; n <= A + B; n++) { if ((A + n)%B==0 && (B + n)%A==0 && A!= B && A != n && B != n) { C = n; } } cout << C << endl; return 0; }