n, m = map(int, input().split())
a = list(map(int, input().split()))
t = list(set(a))
k = ''
s = 0
for i in range(len(t)):
    if a.count(t[i]) >= n:
        s += 1
        k += str(t[i]) + " "
print(s)
print(k)