n, k = map(int, input().split())
usl = list(map(int, input().split()))
c = 0
it = [0 for i in range(max(usl) + 1)]
ans = []

for el in usl:
    it[el] += 1

for i in range(len(it)):
    if it[i] >= n:
        ans.append(i)
        c += 1
print(c)
print(*ans)