e = lambda x: x if s[x] >= n else 0

n, m = map(int,input().split())
a = list(map(int,input().split()))
s = {}
for i in range(m):
    try:
        s[a[i]] += 1
    except:
        s.update({a[i] : 1})
        

a = set(map(e,a))
try:    
    a.remove(0)
except KeyError:
    pass
print(len(a))
for i in a:
    if i != 0:
        print(i, end = ' ')
