program project1;
 var n,k,i,bp:longint;
   a: array [-1000005..1000005] of longint;
   b: array [1..1000005] of longint;
   c:array [1..1000005] of longint;
begin
  bp:=0;
  readln(n,k);
  a[0]:=0;
  for i:=1 to n do begin
  a[i]:=0;
  a[-i]:=0;
  end;

  for i:=1 to n do begin
  read(b[i]);
 a[b[i]]:=a[b[i]]+1;
 if (a[b[i]]=k) then begin
 bp:=bp+1;
 c[bp]:=b[i];
 end;
 end;
  writeln(bp);
  for i:=1 to bp do write (c[i],' ');
end.