{$o-}
program p_i;

{$APPTYPE CONSOLE}

uses
  SysUtils;
var
  fin,fout:text;
  n,m,p,s,k:integer;
begin
  { TODO -oUser -cConsole Main : Insert code here }
  AssignFile(fin,'irrelevant.in');
  AssignFile(fout,'irrelevant.out');
  Reset(fin);
  Rewrite(fout);
  Readln(fin,n,m);
  n:=n-1;
  p:=1;
  s:=0;
  For k:=2 to n+1 do
    begin
      p:=p*(n-k+2) div (k-1);
      if p mod m=0 then s:=s+1;
    end;
  Writeln(fout,s);
  p:=1;
  For k:=2 to n+1 do
    begin
      p:=p*(n-k+2) div (k-1);
      if p mod m=0 then Write(fout,k,' ');
    end;
  CloseFile(fin);
  CloseFile(fout);
end.
