n, m = map(int, input().split())
a = list(map(int, input().split()))
d = {}
for i in a:
    d[i] = d.get(i, 0) + 1
cnt = 0
ans = []
for i in d:
    if d[i] >= n:
        cnt += 1
        ans.append(i)
print(cnt)
print(*ans)