n, m = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
k = ''
ans = 0
s = 1
for i in range(m-1):
    if a[i] == a[i+1]:
        s += 1
    else:
        if s >= n:
            ans += 1
            k += str(a[i]) + " "
        s = 1
if s >= n:
    ans += 1
    k += str(a[m-1]) + " "
print(ans)
print(k)