parseInt(x)=parse(Int,x) parseMap(x::Array{SubString{String},1})=map(parseInt,x) function main() a,b = readline() |> split |> parseMap c = Int[] r = 1 while r <= sqrt(a+b) if (a+b)%r == 0 push!(c,r) push!(c,div(a+b,r)) end r += 1 end c = sort(c) f = 0 for i in 1:length(c) if (a+c[i])%b==0 && (b+c[i])%a==0 && a!=c[i] && b!=c[i] println(c[i]) f = 1 break end end if f == 0 println(-1) end end main()