program prvi;
var
p,n,k,i,j,l,d:longint;
a,b:array[1..10000] of integer;
begin
d:=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
for l:=1 to d do
if a[i]<>b[l] then
begin
d:=d+1;
b[d]:=a[i];
end;
end;
end;
writeln (d);
for i:=1 to d do
write(b[i],' ');
end.