n, k = map(int, input().split())
usl = list(map(int, input().split()))
c = 0
it = []

for i in range(k):
    if usl[i] in it:
        continue
    a = 1
    for el2 in usl[i + 1:]:
        if usl[i] == el2:
            a += 1
    if a >= n:
        c += 1
        it.append(usl[i])
print(c)
print(*it)
