n, m = map(int, input().split())
res = []
a = list(map(int, input().split()))
for i in a:
    if a.count(i) >= n:
        res.append(i)
        a.remove(i)
        a.remove(i)

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