a, b = map(int, input().split())
c = list(map(int, input().split()))
d = {}
s = []
for i in c:
    if not(i in d):
        d[i] = 1
    else:
        d[i] += 1
    if d[i] >= a:
        s.append(i)
s = set(s)
print(len(s))
print(*s)