N, K = map(int, input().split()) win = [False] * (N + K + 2) last = [[False] * (K + 2) for _ in range(N + K + 2)] for S in range(N-1, -1, -1): for L in range(K+1): can_win = False for m in range(1, K+1): if m == L: continue if S + m >= N: continue if not last[S + m][m]: can_win = True break win_state = can_win last[S][L] = win_state result = [] for x in range(1, K+1): S = x L = x if S >= N: continue opponent_can_win = False for y in range(1, K+1): if y == x: continue new_S = S + y new_L = y if new_S >= N: opponent_can_win = True break if not last[new_S][new_L]: opponent_can_win = True break if not opponent_can_win: result.append(x) if result: for num in sorted(result): print(num) else: print(0)