n, m = map(int, input().split())
c = list(map(int, input().split()))
s = list(set(c))
s.sort()
h = dict()
for i in range(len(s)):
    h[s[i]] = 0
for i in range(m):
    h[c[i]] += 1
res = []
for key, value in h.items():
    if value >= n:
        res.append(key)
print(len(res))
print(*res)