print((function (n, m) return (n<=m and 1) or (n%2==0 and n<=2*m and 2) or -1 end)(io.stdin:read("*n"), io.stdin:read("*n")))