program project1;
var m,s,n,k,i:integer ;

var a:array[-1000000..1000000]of integer;

begin
read(n);
read(k);
m:=0;
for i := -1*n to n do
a[i]:=0;

 i:=n;
while i>0 do
begin
    read(s);
    a[s]:=a[s]+1;

    if a[s]=k then
        begin

            m:=m+1;
            //write(s);
        end;
    i:=i-1;
end;
write (m);
writeln;

for i := -1*n to n do
begin
    if a[i]>=k then
        begin
    write (i);
    write(' ');
        end;
end;

end.