a, b = map(int, input().split())
c = list(map(int, input().split()))
d = []
e = []
for i in c:
    d.append(c.count(i))
for i in range(len(d)):
    if d[i] >= a:
        e.append(c[i])
print(len(set(e)))
print(*set(e))