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

my_list = list(map(int, input().split()))
ans = []

count = 0
for elem in my_list:
    if my_list.count(elem) > 1 and elem not in ans:
        count += 1
        ans.append(elem)

print(count)
print(*ans)