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

lii = input().split()

def dsds(list, n):
                lii2 = {x for x in list if list.count(x) >= n}
                print(len(lii2))
                print(*lii2)

dsds(lii, n)


