function fak(n:integer):integer;
var i,p:integer;
begin
p:=1;
if n=0 then fak:=1
   else
   for i:=1 to n do
   p:=p*i;
fak:=p;
end;
var p, n,m,i,j,k:integer;

  h:array[1..100] of integer;

begin
   assignfile(input,'irrelevant.in'); reset(input);
   assignfile(output,'irrelevant.out'); rewrite(output);
   read(n,m);
   j:=0;
   for i:=1 to n do
   begin
     p:=trunc(fak(n-1)/(fak(n-i)*fak(i-1)));
     if p mod m =0 then
     begin
     j:=j+1;
     h[j]:=i;
     end;
   end;
   if j>0 then
   begin
     writeln(j);
     for i:=1 to j do
     write(h[i],' ');
   end else write('0');
end.