a,b=gets.split.map &:to_i d=a.gcd b k=(d*(1.0/a+1.0/b)).to_i c=a*(b/d*k-1)-b c+=a*b/d while c<=0 p a!=c&&b!=c&&(a+b)%c==0&&(a+c)%b==0&&(b+c)%a==0 ? c : -1