n, m = map(int, input().split())
c = map(int, input().split())
d = {}
for i in c:
    d[i] = d.get(i, 0) + 1
result = list(filter(lambda x: d[x] >= n, d))
print(len(result))
print(*result)
# n, q, k = map(int, input().split())
# p = list(map(int, input().split()))
# dela = {i: 0 for i in range(1, n+1)}
# lr = [list(map(int, input().split())) for _ in range(q)]
# current_list = list(dela.keys())
# for l, r in lr:
#     do, srez, posle = current_list[:l-1], current_list[l-1:r], current_list[r:]
#     for delo, prioritet in zip(srez, p):
#         dela[delo] = prioritet
#     del current_list[l-1:r]
#     current_list = do + sorted(srez, key=lambda x: dela[x]) + posle
# print(current_list[k-1])
