from collections import Counter
n, m = map(int,input().split())
d = list(map(int,input().split()))
cnt = Counter()
ans = []
for i in d:
    cnt[i] += 1
    if cnt[i] % n == 0:
        ans += [i]
print(len(ans))
print(*ans)
