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