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])
h=1
s=0
s1=0
b=[]
while h>0:
    c=a[s1]
    s2=-1
    for i in range(len(a)):
        if a[i]==c:
            s2+=1
    if s2==day-1 or s2>day-1:
        g=0
        for i in range(len(b)):
            if c==b[i]:
                g+=1
        if g==0:
            s+=1
            b.append(c)
    s1+=1
    if s1>len(a)-1:
        h-=1
        break
print(s)
for i in b:
    print(i, end='')
    if i!=b[len(b)-1]:
        print(end=' ')

