program iii;

var  pir,pp,ns,nvs,nas : array [1 .. 10000 ] of longint;
     gd : array [1 .. 100000 ] of longint;
     s,a,nx,good,n,pi,i,j,jj,m,m1 : longint;
     bad:boolean;
     f:text;
begin
assign ( f, 'irrelevant.in');
reset ( f );
readln ( f,n,m );
close (f);
dec (n);
m1:=m;
i:=2;
while i <= m do
 begin
    if m mod i = 0 then
     begin
      inc (pi);
      pp [ pi] :=i;
     end;
    while m mod i = 0  do
     begin
      m:= m div i;
      inc (pir[pi]);
     end;
    inc (i);
 end;
 nx:=n;
 for i := 1 to pi do
  begin
    a:=pp[i];
    s:=0;
    while nx >=a do
     begin
       s:=s+nx div a;
       if (maxlongint div pp[i] <= a )then break;
       a:=a *pp[i];
     end;
     ns[i]:=s;
  end;
 nx:=n;
 for i := 1 to pi do
  begin
    a:=pp[i];
    s:=0;
    while nx >=a do
     begin
       s:=s+nx div a;
       if (maxlongint div pp[i] <= a )then break;
       a:=a *pp[i];
     end;
     nvs[i]:=s;
  end;
  for i := 1 to pi do
   nas[i]:=0;
   for i := 0 to n do
    begin
    for j:= 1 to pi do
    begin
      jj:=i;
      while (jj<>0)and (jj mod pp [ j] =0)do
       begin
       inc (nas[j]);
       jj:=jj div pp[j];
       end;
     end;
     bad:=false;
      for j := 1 to pi do
       if nas[j]+nvs[j]+pir[j] >ns[j] then      begin
         bad:=true;
         break;
        end;
      if not ( bad ) then
       begin
       inc ( good );
         gd[good]:=i+1;
       end;
       for j := 1 to pi do
       begin
      jj:=n-i;
      while (jj<>0)and(jj mod pp [ j] =0)do
       begin
       dec (nvs[j]);
       jj:= jj div pp[j];
       end;
        end;
    end;
    assign ( f, 'irrelevant.out');
    rewrite ( f );
    writeln ( f, good);
    for j := 1 to good do
     write ( f, gd[j], ' ');
    close ( f ); 
end.
