type    VLongInt={LongInt}Int64;
const   filein={'irr.in'}'irrelevant.in';
        outfile={'irr.out'}'irrelevant.out';
        maxn=100001;
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);
  k:=0; Cnk:=1;
  For i:=2 to N do
  begin
{   If Cnk>0 then Cnk:=(Cnk)*((((n-1)-(i-1)+1) div (i-1))mod M) else
   Cnk:=((((n-1)-(i-1)+1) div (i-1))mod M);
   Cnk:=Cnk mod M;}
   Cnk:=(Cnk)*((((n-1)-(i-1)+1)))div (i-1);
   if (Cnk mod M=0) then
   begin
    inc(k);
    a[i]:=1;
   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.