n, k = map(int, input().split())
usl = list(map(int, input().split()))
ans = []
sc = 0
usl0 = list(set(usl))

for el in usl0:
    if el in ans:
        continue
    if usl.count(el) >= n:
        sc += 1
        ans.append(el)

print(sc)
print(*ans)
