n, k = gets.strip.split(' ').map(&:to_i) r = (n - 1) % (k + 1) if n % (k + 1) == 1 puts "0" else puts r end STDOUT.flush i = 1 while true opp = gets.strip.to_i if opp >= n break end puts i * (k + 1) + r STDOUT.flush i += 1 end