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])
        for j in range(n):
            a.remove(a[i])
            m -= 1
            i -= 1
    i += 1

print(len(res))
print(*res)