program irrelevant;

{$APPTYPE CONSOLE}
var
 i,n,kol,m:integer;
 arr:array[1..100000]of int64;
 tmp:int64;

function get(n,k:integer):int64;
var
 s1,s2:int64;
begin
 if (k=0)or(k=n)or(n=0) then get:=1
 else
 begin
  s1:=get(n-1,k-1);
  s2:=get(n-1,k);
  get:=s1+s2;
 end;
end;
begin
 assign(input,'irrelevant.in');
 reset(input);
 assign(output,'irrelevant.out');
 rewrite(output);
 readln(n,m);
 kol:=0;
 for i:=0 to n-1 do
 begin
  tmp:=get(n-1,i);
  if (tmp mod m =0)then
  begin
   inc(kol);
   arr[kol]:=tmp;
  end;
 end;
 writeln(kol);
 for i:=1 to kol do write(arr[i],' ');
 close(input);
 close(output);
end.
