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


A = [int(i) for i in input().split()]
B = []


for i in range(m):
  check = A[i]
  number = 0
  for j in range(m):
    if(check == A[j]):
      number += 1
  if(number >= n):
    B.append(check)
li = []
for i in B:
  if i not in li:
    li.append(i)
string = ''
for el in li:
    string += str(el)
    string += ' '
print(len(li))
print(string)