n, k = map(int, input().split())
usl = list(map(int, input().split()))
usl.sort()
c = 0
a = usl[0]
sc = 0
ans = []

for el in usl:
    if el == a:
        c += 1
    else:
        if c >= n:
            sc += 1
            ans.append(a)
        a = el
        c = 1

print(sc)
print(*ans)
