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

d = dict()

for i in c:
    if i in d:
        d[i]+=1
    else:
        d[i]=1

ans = []        
for i in d:
    if d[i]>=2:
        ans.append(i)
print(len(ans))
print(*ans)
        
