n, m = map(int, input().split())
arr =  list(map(int, input().split()))
a = set()
ma = dict()
for i in arr:
    if i in ma:
        ma[i] += 1
        if ma[i] >= n:
            a.add(i)
    else:
        ma[i] = 1
print(len(a))
print(*a)