n,m = map(int,input().split())
list_1 = list(map(int,input().split()))
b = []
count = 0
for i in range(len(list_1)):
    if list_1.count(list_1[i]) >= n:
        b.append(list_1[i])

print(len(set(b)))
print(*set(b))

