#include using namespace std; using ll = long long; #define fi first #define se second int main(){ int a,b; cin >> a >> b; for(int c=1;c < a+b;c++) { if((a+b)%c == (b+c)%a && (c+a)%b == (a+b)%c && (b+c)%a==0){ cout << c << endl; return 0; } } cout << -1 << endl; }