#include using namespace std; using ll = long long; int main() { cin.tie(0); ios::sync_with_stdio(false); int a, b; cin >> a >> b; int c = -1; for (int i = 1; i * i <= a + b; i++) { if (i == a || i == b) continue; if ((a + b) % i == 0 && (i + b) % a == 0 && (i + a) % b == 0) { c = i; break; } } cout << c << endl; return 0; }