a,b =map(int,input().split())
s = list(map(int,input().split()))
l=0
l1 = []
d = {}
for i in range(b):
    if s[i] not in d:
        d[s[i]] =1
    else:
        d[s[i]] +=1

        if d[s[i]] < 3:
            l1.append(s[i])
            l += 1
if l ==0:
    print(b)
    print(*s)
else:
    print(l)
    print(*l1)


