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

list = list(map(int, input().split()))

a = []

for i in list:
    if list.count(i) > 1:
        a.append(i)
        for j in range(list.count(i)):
            list.pop(list.index(i))
        
print(len(a))
print(*a)
