a=input().split()
day, n=a
day, n=int(day), int(n)
a=input().split()
for i in range(len(a)):
    a[i]=int(a[i])
kl=0
b=[]
if day==n :
    print(day)
    for i in a:
        print(i, end=' ')
else:
    dup = {x for x in a if a.count(x) > 1}
    for i in dup:
        kl2=0
        for j in a:
            if i==j:
                kl2+=1
        if kl2>=day:
            kl+=1;b.append(i)
    print(kl)
    for i in b:
        print(i, end=' ')
 

