n, m = map(int, input().split())
l2 =[]
for i in range(m):
    l2.append(0)
l3 = []
s = input()
l = s.split()
for i in l:
    l2[int(i)]+=1

for i in range(len(l2)):
    if l2[i] >= 2:
        l3.append(i)
print(len(l3)
print(*l3[1:], l3[0], sep=' ')