{To Send}
type    VLongInt=int64;
const   filein='irrelevant.in';
        outfile='irrelevant.out';
        maxn=100001;
{To check}
{type    VLongInt=LongInt;
const   filein='irr.in';
        outfile='irr.out';
        maxn=10000;}
var     i,j,k,l,m,n                     : LongInt;
        A                               : array[1..maxn] of byte;
        Cnk                             : VLongInt;
        f                               : Boolean;

BEGIN
 fillchar(a,sizeof(a),0);
 Assign(Input,FileIn);
 Assign(Output,OutFile);
 Rewrite(Output);
 Reset(Input);
  Read(n,m); if m<2 then halt(200);
  k:=0; Cnk:=1;
  For i:=2 to ((N+1) div 2) do
  begin
   l:=((((n-1)-(i-1)+1)));
{   If (Cnk mod M>0) then
   begin
    Cnk:=Cnk mod M;
    Cnk:=(Cnk*L) div(i-1);
   end
   else}
    Cnk:=(Cnk*L) div (i-1);
   if (Cnk mod M=0) then
   begin
    inc(k);
    a[i]:=1;
    a[N-i+1]:=1;
    if n-i+1<>i then inc(k);
   end;
  end;

  writeln(K); f:=false;
  for i:=1 to N do
   if a[i]=1 then
   begin
    if f then write(' ');
    f:=true;
    write(i);
   end;

 Close(input);
 Close(Output);
END.