n, m = map(int, input().split())
l = list(map(int, input().split()))

lst = set()
for i in range(len(set(l))):
    if l[i] not in lst:
        p = l.count(l[i])
        if p >= n:
            lst.add(l[i])
print(len(lst))
print(*lst)

