NK = list(map(int, input().split()))
polja = list(map(int, input().split()))
s = 0
k = NK[1]
reci = list(set(polja))
broj = []
lom = []
i = 0
for rec in reci:
    broj.append(polja.count(rec))

while i < len(reci):
    if broj[i] >= k:
        s = s + 1
        lom.append(reci[i])
    i = i + 1

print(s)
i = 0
while True:
    try:

        print(lom[i], "", end="")
        i = i + 1
    except:
        break