q=input().split()
n=int(q[0])
m=int(q[1])
q=input().split()
count=1
trackVar=0
output=[]
x=[]
b=True
for i in range(0, m):
    trackVar=int(q[i])
    for j in range(i+1, m):
        if int(q[j])==trackVar:
            count+=1
    if count>=n:
        for i in range(0, len(output)):
            if output[i]==trackVar:
                b=False
        if b:
            output.append(trackVar)
    b=True
    count=1
print(len(output))
print(*output)