n, m = map(int, input().split())
z = int(1e9 + 1)
cnt = [0]*z
ans = []
for i in map(int, input().split()):
    cnt[i] += 1
    if cnt[i] >= n:
        cnt[i] = -1e9
        ans.append(i)
print(len(ans))
print(*ans)
