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

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

