n, m = map(int, input().split())
m+=1
res = []
i = 0
a = list(map(int, input().split()))

while ((m := m-1) >= 0):
    if (a.count(a[i]) >= n):
        res.append(a[i])
        index = a[i]
        for j in range(n):
            a.remove(index)
            i -= 1
            m -= 1
    i+=1

res = set(res)
print(len(res))
print(*res)