a = input().split()
a[0] = int(a[0])

lst = input().split()
lst.sort()

variants = []
cnt = 1
for i in range(1,len(lst)):
	if lst[i-1] == lst[i]:
		cnt += 1
		if cnt == a[0]:
			variants.append(lst[i])
	else:
		cnt = 1
print(len(variants))
ans = ''
for i in variants:
	ans = ans + i + ' '
print(ans[:-1])
