n = input().split()

a = n[0]

c = input().split()
e = ""
r = []
for i in range(int(n[1])):
    r = c[i]
    j = c.count(r)
    if j >= int(a):
        if c[i] not in e:
            r += c[i]
            e += c[i]
            e += " "

print(len(r))
print(e)
