from collections import Counter

n, m = map(int, input().split())
c = list(map(int, input().split()))
csd = Counter(c)
v = [item for item in csd if csd[item] >= n]
vm = len(v)
print(vm)
print(' '.join(map(str, v)))
