from itertools import groupby
nm = input('')
nm = nm.split()
n = nm[0]
m = nm[1]

prices = input('')
prices = prices.split()
#if len(prices) != m:
#    print("Error!")

def find_repeated_elements(number, listt):
    repeated_elements = []
    for element in listt:
        if listt.count(element) >= int(number) and element not in repeated_elements:
            repeated_elements.append(element)
    return repeated_elements

repeated_elementsS = find_repeated_elements(n, prices)
repeatednumber = len(repeated_elementsS)
print(repeatednumber)
print(*repeated_elementsS)