{$R-,Q-,S-,I-}
{$APPTYPE CONSOLE}

 Const MaxP=100000;

 Type Mas=Array [1..MaxP] of integer;
  int64=integer;

Var n,m : int64;
  numPr : Integer;
     Pr : Array [1..MaxP] of integer;
     r1,r2 : Mas;
   ans : Array [1..MaxP] of integer;
   Rasa : Array [1..100000,0..35] of integer;
   cn : Array [1..100000] of integer;
  rasm : Array [1..50,1..2] of integer;
  crasmm : integer;
   na : integer;

Function checkp(num : integer) : boolean;
  var I,sqnum : integer;
 Begin
  sqnum:=round(sqrt(num));
  for i:=1 to numpr do
   if pr[i]>sqnum then break else
  if num mod pr[i]=0 then Begin
                        checkp:=false;
                        exit;
                       End;
  checkp:=true;
 End;

Procedure Ras(num : Int64; var r : Mas);
  var i : integer;
 Begin
  for i:=1 to rasa[num,0] do
   inc(r[cn[rasa[num,i]]]);
 End;

Procedure RasAll;
  Var i,j : integer;
     mn,num : int64;
 Begin
  for i:=1 to 100000 do
   Begin
    rasa[i,0]:=0;
    num:=i;
    mn:=0;
    if cn[i]<>0 then
     Begin
      rasa[i,0]:=1;
      rasa[i,1]:=i;
     End else
    repeat
     inc(mn);
      while num mod pr[mn]=0 do
       Begin
        num:=num div pr[mn];
        inc(rasa[i,0]);
       rasa[i,rasa[i,0]]:=pr[mn];
       for j:=1 to rasa[num,0] do
         Begin
          inc(rasa[i,0]);
          rasa[i,rasa[i,0]]:=rasa[num,j];
         End;
         break;
       End;
     if num<>i then break;  
     if num<2 then break;
    until false;
   End;
 End;

Procedure del(num : int64; var r : Mas);
  var I :integer;
 Begin
  for i:=1 to rasa[num,0] do
   dec(r[cn[rasa[num,i]]]);
 End;

function check(num : Int64) : boolean;
  var i : integer;
 Begin
  for i:=1 to crasmm do
   if r1[cn[rasm[i,1]]]<rasm[i,2] then Begin
                                              check:=false;
                                              exit;
                                             End;
  check:=true;
 end;

Procedure Solve;
   Var i : integer;
 Begin
   fillchar(r1,sizeof(r1),0);
  for i:=n-1 downto 1 do
   Begin
    ras(i,r1);
    if n-i<>0 then del(n-i,r1);
    if check(m) then
       Begin
        inc(na);
        ans[na]:=n-i+1;
       End;
   End;
  writeln(na);
  for i:=1 to na do writeln(ans[i],' ');
 End;

Procedure Rasmm;
  Var col,mn : Integer;
   num : int64;
 Begin
  num:=m;mn:=0;
  repeat
   inc(mn);
   if mn>numpr then Begin
                    writeln(0);
                    halt(0);
                    End;
   col:=0;
    while num mod pr[mn]=0 do
     Begin
      num:=num div pr[mn];
      inc(col);
     End;
      if col<>0 then
       Begin
        inc(crasmm);
        rasm[crasmm,1]:=pr[mn];
        rasm[crasmm,2]:=col;
       End; 
   if num<2 then break;
  until false;
 End;

Procedure PreSolve;
  Var i: Integer;
 BEgin
  numpr:=0;na:=0;
  for i:=2 to 100000 do
   if checkp(i) then
    Begin
     inc(numpr);
     cn[i]:=numpr;
     pr[numpr]:=i;
    End;
   RasAll;
   crasmm:=0;
   rasmm;
 End;

begin
 Assign(input,'irrelevant.in');Reset(input);
 Assign(output,'irrelevant.out');Rewrite(output);
 read(n,m);
 PreSolve;
 Solve;
end.

