program i_1;

{$APPTYPE CONSOLE}

uses
  SysUtils;

var
   n,m:integer;
   i,j:integer;
   max:integer;
   a,b,c:array[0..100000]of int64;

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

   read(n,m);
   a[0]:=0;
   b[0]:=0;
   a[1]:=1;
   for i:= 2 to n do begin
      for j:=1 to i do begin
         if i mod 2 = 0 then begin
             b[j]:=a[j-1]+a[j];
         end else begin
             a[j]:=b[j-1]+b[j];
         end;
      end;
   end;

   max:=0;
   if n mod 2 = 0 then begin
      for i:=1 to n do begin
         if b[i] mod m = 0 then begin max:=max+1; c[max]:=i; end;
      end;
   end else begin
      for i:=1 to n do begin
         if a[i] mod m = 0 then begin max:=max+1; c[max]:=i; end;
      end;
   end;
   writeln(max);
   for i:=1 to max do write(c[i],' ');
   close(input);
   close(output);

end.
