def find_possible_costs(n, m, costs):
    costs_dict = {}
    for cost in costs:
        if cost in costs_dict:
            costs_dict[cost] += 1
        else:
            costs_dict[cost] = 1

    possible_costs = []
    for cost, count in costs_dict.items():
        if count >= n:
            possible_costs.append(cost)

    return possible_costs


# чтение входных данных
n, m = map(int, input().split())
costs = list(map(int, input().split()))

# поиск возможных стоимостей
possible_costs = find_possible_costs(n, m, costs)

# вывод результатов
print(len(possible_costs))
print(*possible_costs)