n, m = list(map(int, input().split()))
c = list(map(int, input().split()))

s = set(c)
a = dict()
cnt = 0
res = []

for i in s:
    if c.count(i) >= n:
        a[i] = c.count(i)
        cnt += 1

for key, value in a.items():
    if value >= n:
        res.append(key)

print(cnt)
print(*res)
