program irrelevant;
{$APPTYPE CONSOLE}
const
	max_n = 100002;
   num_div = 32;
type
	iinteger	= integer;
	{integer	= int64;}
   num = array [0..num_div, 0..1] of integer;
var
	divisors: array [0..max_n] of integer;
   res: array [0..max_n] of boolean;
   cnk: array [0..max_n] of integer;
   mm, buf: num;
   i, j, last: iinteger;
   n, m, sum, nn, b: integer;

procedure decomp(a: integer; var res: num);
var
	b, i, last: integer;
begin
	fillchar(res, sizeof(res), 0);
   if a = 0 then
   	exit;
   i:=0;
   last:=0;
	while a <> 1 do begin
      b:=divisors[a];
      if b <> last then
      	inc(i);
      res[i, 0]:=b;
      inc(res[i, 1]);
      a:=a div b;
      last:=b;
   end;
end;

function succ: boolean;
var
	i: iinteger;
begin
	for i:=1 to nn do begin
   	if mm[i, 1] > cnk[mm[i, 0]] then begin
      	succ:=false;
         exit;
      end;
   end;
   succ:=true;
end;

procedure inc_cnk(k: integer);
var
	i: integer;
begin
	decomp(n - 1 - k + 1, buf);
   i:=1;
   while buf[i, 0] <> 0 do begin
   	inc(cnk[buf[i, 0]], buf[i, 1]);
   	inc(i);
   end;

   decomp(k, buf);
   i:=1;
   while buf[i, 0] <> 0 do begin
   	dec(cnk[buf[i, 0]], buf[i, 1]);
   	inc(i);
   end;
end;

begin
	assign(input, 'irrelevant.in');
   reset(input);
   assign(output, 'irrelevant.out');
   rewrite(output);
   readln(n, m);
   fillchar(divisors, sizeof(divisors), 0);
   for i:=1 to max_n do begin
   	j:=2;
      b:=round(SQRT(i)) + 1;
      while (j <= b) and (i mod j <> 0) do
      	inc(j);
      if j > b then
      	j:=i;
      divisors[i]:=j;
   end;

   nn:=0;
   b:=round(SQRT(m)) + 1;
   i:=2;
   last:=0;
   fillchar(mm, sizeof(mm), 0);
   while (i <= b) and (i <= m) do begin
   	if m mod i = 0 then begin
      	m:=m div i;
         if i <> last then
         	inc(nn);
         mm[nn, 0]:=i;
         inc(mm[nn, 1]);
         last:=i;
      end else
      	inc(i);
   end;
   if m <> 1 then begin
   	inc(nn);
      mm[nn, 0]:=m;
      mm[nn, 1]:=1;
   end;

   {while mm[nn, 0] <> 0 do
   	inc(nn);
   dec(nn);}
   fillchar(cnk, sizeof(cnk), 0);
   fillchar(res, sizeof(res), false);
   sum:=0;
   for i:=0 to n - 1 do begin
   	if succ then begin
      	res[i + 1]:=true;
         inc(sum);
      end;
      inc_cnk(i + 1);
      {writeln(i + 1);
      for j:=1 to 10 do
      	write(cnk[j], ' ');
      writeln;}
   end;
   writeln(sum);
   for i:=1 to n do
   	if res[i] then
      	write(i, ' ');
end.
