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

cost_counts = {}

for cost in costs:
    if cost not in cost_counts:
        cost_counts[cost] = 1
    else:
        cost_counts[cost] += 1

possible_costs = 0
for cost in cost_counts:
    if cost_counts[cost] >= n:
        possible_costs += 1

possible_cost_values = []
for cost in cost_counts:
    if cost_counts[cost] >= n:
        possible_cost_values.append(cost)

print(possible_costs)
print(" ".join(map(str, possible_cost_values)))
