n, m = map(int, input().split())
s = list(map(int, input().split()))
d = dict()
for i in s:
    if i in d:
        d[i] += 1
    else:
        d[i] = 1
k = 0
l = []
for i in d:
    if d[i] >= n:
        k += 1
        l.append(i)
print(k)
for i in l:
    print(i, end=' ')