X = gets.to_i MAX = 2 * 10**18 (0..62).each do |m| n = X ^ m if 1 <= n and n <= MAX and n.to_s(2).count(?1) == m puts n exit end end puts -1