from collections import Counter

n,m = map(int, input().split())
c = [int(a) for a in input().split()]
list = []

for i in c:
    if c.count(i) >= n:
        list.append(i)
        c.remove(i)

print(len(set(list)))
print(' '.join(map(str, set(list))))