#include using namespace std; #define rep(i,n) for(ll i=0;i<(n);++i) using ll = long long; using pll = pair; constexpr ll INF = (1LL<<60); constexpr ll MOD = (1e9+7); //constexpr ll MOD = (998244353); template bool chmax(T &a,const T &b){if(a bool chmin(T &a,const T &b){if(a>b){a=b;return 1;}return 0;} void dump(){cout< void dump(T&& h, Ts&&... t){cout<(t)...);} template istream &operator>>(istream&is,vector&v){for(auto &elemnt:v)is>>elemnt;return is;} template istream &operator>>(istream&is,pair&p){is>>p.first>>p.second;return is;} templatevector make_vector(size_t a){return vector(a);} templateauto make_vector(size_t a, Ts... ts){return vector(ts...))>(a, make_vector(ts...));} void solve1();void solve2(); int main(){ solve1(); return 0; } std::vector divisor(ll n){ std::vector div; for(ll p=1;p*p<=n;++p){ if(n%p==0){ div.push_back(p); if(p*p!=n)div.push_back(n/p); } } std::sort(div.begin(),div.end()); return div; } void solve1(){ ll a,b; cin>>a>>b; ll t = a+b; auto div = divisor(t); ll ans = -1; for(auto c:div){ bool x,y,z; x = (a+b)%c==0; y = (a+c)%b==0; z = (b+c)%a==0; if(x and y and z)ans=c; } cout<<(ans)<