N,K = map(int,input().split()) x0 = N % (K+1) x = x0 print(x) while 1: y = int(input()) print("a",y) if y >= N: exit() x = y + K + 1 - (y-x0) % (K+1) print(x)