n,m = input().split()
n,m = int(n),int(m)
s = [i for i in input().split()]
q = []
for i in s:
    if s.count(i) >= n:
        if q.count(i) == 0:
            q.append(i)
        while i in s:
            s.remove(i)
print(len(q))
print(*q)