program Project2;
{$O-}
{$APPTYPE CONSOLE}

type TPrime=record

  number:integer;
  degree:integer;

end;

function leg(a,m:integer):integer;

var tmp:integer;

begin
  result:=0;
  tmp:=m;
  while (a>=tmp) do
  begin
    result:=result+(a div tmp);
    tmp:=tmp*m;

  end;

end;


var Primes:array[1..300] of TPrime;
    index:integer;
    ans:array[1..100000] of integer;

function Cnkm(n,k:integer):boolean;

var i:integer;

begin
  Cnkm:=true;
  if (n=0) then
  begin
    Cnkm:=false;
    exit;
  end;
  for i:=1 to index do
    if ((Leg(n,Primes[i].number)-Leg(n-k,Primes[i].number)-Leg(k,Primes[i].number))<Primes[i].degree) then
    begin
      Cnkm:=false;
      exit;
    end;
end;

var FileIn,FileOut:text;
    n:integer;
    m,mt:integer;
    i:integer;
    ds:integer;
    nans:integer;
begin
  assign(FileIn,'irrelevant.in');
  assign(FileOut,'irrelevant.out');
  rewrite(FileOut);
  reset(FileIn);
  read(FileIn,n,m);
  index:=0;
  mt:=m;
  ds:=2;
  repeat
    if (mt mod ds=0) then
    begin
      inc(index);
      Primes[index].number:=ds;
      while
        ((mt mod ds)=0) do
        begin
          inc(Primes[index].degree);
          mt:=mt div ds;
        end;
    end;
    inc(ds);
  until (mt=1) or (ds*ds>mt);
  if (mt<>1) then
  begin
    inc(Index);
    Primes[index].number:=mt;
    Primes[index].degree:=1;
  end;
  nans:=0;
  for i:=1 to n do
  begin
    if (Cnkm(n-1,i-1)) then
    begin
      inc(nans);
      ans[nans]:=i;
    end;

  end;
  writeln(FileOut,nans);
  for i:=1 to nans do
    write(FileOut,ans[i],' ');

  close(FileIn);
  close(FileOut);
end.
