n,m=map(int,input().split())
c=list(map(int,input().split()))
mas=[]
k=0
for i in range(len(c)):
    if c.count(c[i])>=n and c[i] not in mas:
        mas.append(c[i])
        k+=1
print(k)
print(*mas)