a = input()
a = a.split()
n = int(a[0])
m = int(a[1])
c = input()
c = c.split()
c_1=[]
answer = []
for i in c:
    if i not in c_1:
        c_1.append(i)

for i in c_1:
    if c.count(i)>=n:
        answer.append(i)
print(len(answer))
str = ""
for i in range(len(answer)-1):
    str+=answer[i]
    str+=" "
str+=answer[-1]
print(str)

