program Irrelevant;

{$APPTYPE CONSOLE}

var
 i,k,k1,k2,j,l,m,n:integer;
 x,y,z:integer;
 res:array[0..10000] of integer;
 label ex;

function findPow(l:integer):integer;
var dd,jj:integer;
begin
 dd:=0;
 while (l>=m) do
  begin
   jj:=l div m;
   inc(dd,jj);
   l:=jj;
  end;
  findPow:=dd;
end;

function findCoef(n,k:integer):integer;
begin
 if n=2 then findcoef:=1 else
 if k=2 then findCoef:=1+findCoef(n-1,k)
 else
  if k=n-1 then findCoef:=1+findCoef(n-1,k-1)
 else
  findCoef:=findCoef(n-1,k-1)+findCoef(n-1,k);
end;

begin
 assign(input,'irrelevant.in');
 assign(output,'irrelevant.out');
 reset(input);
 rewrite(output);

 readln(n,m);
{ n:=n div 2+1;}

 x:=0;
 l:=n;

{  x:=findPow(n);
  z:=x;
  y:=0;
  k1:=0;
  k2:=n;}
  res[0]:=0;

  for k:=2 to n-1 do
   begin
{    dec(k2);
    if
    inc(k1);
    dec(k2);
    if (x>=y+z) then}

    if findCoef(n,k) mod m=0 then
     begin
      inc(res[0]);
      res[res[0]]:=k;
     end;
   end;

writeln(res[0]);
for i:=1 to res[0] do
 write(res[i],' ');

ex:
 close(input);
 close(output);
end.

