{$APPTYPE CONSOLE}
{$Q+,R+}

uses SysUtils;

const maxP=10000;
      p = 1;
      c = 2;

type Art = array[1..maxP,p..c] of integer;      

var M,n:integer;
    Pr:array[1..maxP] of integer;
    PrC:integer;
    CurPr:array[1..maxP] of integer;
    NPrC,MPrC:integer;
    NPr,MPr:ArT;
    i,j:integer;
    good:boolean;
    Ans:array[1..100000+239] of integer;
    AnsC:integer; 

procedure generatePrimes;
var i,j:integer;
    isp:boolean;
begin
 PrC:=1;
 Pr[1]:=2;
 for i:=3 to 100*1000 +239 do
  begin
   isp:=true;
   for j:=1 to PrC do
    begin
     if Pr[j]*Pr[j]>i then break;
     if i mod Pr[j] = 0 then begin isp:=false; break; end;
    end;
   if isp then begin inc(PrC); Pr[PrC]:=i; end; 
  end;
end;

function factor(m:integer; var MprC:integer; var Mpr:art):boolean;
var i:integer;
begin
 MPrC:=0;
 for i:=1 to PrC do
  begin
   if M mod Pr[i] = 0 then
    begin
     inc(MprC);
     Mpr[MprC,p]:=i;
     Mpr[MprC,c]:=0;
    end;

   while M mod Pr[i]=0 do
    begin
     M:=M div Pr[i];
     inc(MPr[MprC,c]);
    end;
  end;

 Result:=M = 1; 
end;

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

 read(n,m);
 dec(N);
 if n<=1 then
  begin
   writeln('0');
   halt(0);
  end;

 GeneratePrimes;

 if not factor(m,MprC,Mpr) then begin writeln('0'); halt(0); end;

 fillchar(curPr,sizeof(CurPr),0);

 AnsC:=0;

 for I:=0 to N-1 do
  begin
   factor(N-i,NprC,Npr);
   for j:=1 to NprC do
    inc(CurPr[Npr[j,p]],Npr[j,c]);
   factor(i+1,NprC,Npr);
   for j:=1 to NprC do
    dec(CurPr[Npr[j,p]],Npr[j,c]);

   good:=true; 
   for j:=1 to MprC do
    if CurPr[Mpr[j,p]]<Mpr[j,c] then begin good:=false; break; end;
   if good then begin inc(ansC); Ans[AnsC]:=i+1; end;
  end;

 writeln(AnsC);
 for i:=1 to AnsC do
  write(Ans[i] + 1,' ');
 writeln; 
end.
