program prvi;
var
p,n,k,i,j,s,l,d:longint;
a,b:array[1..10000] of longint;
begin
d:=0;
s:=0;
readln(n,k);
for i:=1 to n do
    begin
readln(a[i]);
p:=1;
for j:=1 to i-1 do
if a[j]=a[i] then
p:=p+1;
if p>=k then
        begin
if d=0 then
begin
d:=d+1;
b[d]:=a[i];
end
else 
begin
for l:=1 to d do
if a[i]=b[l] then
s:=1;
if s=0 then
    begin
d:=d+1;
b[d]:=a[i];
    end;
        end;
end;
    end;
writeln (d);
for i:=1 to d do
writeln(b[i]);
end.