a, b = map(int, input().split())
numbers = list(map(int, input().split()))

count_dict = {}

for num in numbers:
    if num in count_dict:
        count_dict[num] += 1
    else:
        count_dict[num] = 1

repeating_numbers = [num for num, count in count_dict.items() if count > 1]

print(len(repeating_numbers)) 
print(*repeating_numbers) 
