
p=0
n, m = map(int, input().split())
v = input().split()
for i in range(m):
    count = 0
    for j in range(i, m):
        if int(v[j])==p:
            continue
        elif int(v[j]) == int(v[i]):
            count += 1
    if count==3:
        print(count)
        p=int(v[i])
        print(p, end=" ")
    elif count >= n:
        b = int(v[i])
        print(b, end=" ")



