n, m = map(int, input().split())
l = list(map(int, input().split()))


ans = 0
s = ''
for i in range(m):
    if str(l[i]) not in s:
        p = l.count(l[i])
        if p >= n:
            s += str(l[i])
            s += ' '
            ans += 1
        
print(ans)
print(s[:-1])
