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

cost = dict()
poss_cost = set()
for i in price:
    cost[i] = cost.get(i, 0) + 1
    if cost[i] >= n:
        poss_cost.add(i)

print(len(poss_cost))
print(*poss_cost)