program project1;

var a:array of longint;
    d:array of longint;
    c:array of longint;
    i,j,x,n,k,db:longint;

begin

read(n,k);
setlength(d,n);
//for i:=1 to n do read(d[i]);
i:=1;
  repeat
  read(d[i]);
  i:=i+1;
  until(i=n+1);
setlength(a,(2*n)+1);
setlength(c,1);

db:=0;
j:=1;
//for i:=1 to n do
//  begin
i:=1;
  repeat
  x:=d[i];
  a[n+1+x]:=a[n+1+x]+1;
  i:=i+1;
  if (a[n+1+x] = k) then
    begin
    db:=db+1;
    setlength(c,db+1);
    c[j]:=x;
    j:=j+1;
    end;
//  end;
  until(i=n+1);

writeln(db);
//for i:=1 to db do write(c[i],' ');
i:=1;
  repeat
  write(c[i],' ');
  i:=i+1;
  until(i=db+1);

end.