from collections import Counter
n,m = map(int,input().split())
c = [int(x) for x in input().split()]
h = list(map(lambda x: x[0],filter(lambda x: x[1] > 1, Counter(c).items())))
print(len(h))
print(*h)