# import sys
# import os
# import io
#
# input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
# output = sys.stdout.buffer.write
#
#
# def print(*values, sep=' ', end='\n'):
#     output(sep.join(str(value) for value in values).encode())


from collections import Counter

n, m = map(int, input().split())
k = list(map(int, input().split()))
a = Counter(k)
ans = []
for i in a:
    if a[i] >= n:
        ans.append(i)
print(len(ans))
print(*ans)
