program xx;
const inp='irrelevant.in';
     outp='irrelevant.out';
var i,j,n,m,k,s,tt,pn:longint;
    a,xar,p:array[1..100001]of longint;

function find(a,b:longint):longint;
var t:longint;
begin
 t:=0;
 while a>0 do
  begin
   t:=t+(a div b);
   a:=a div b;
  end;
 find:=t;
end;

begin
 assign(input,inp); reset(input);
 assign(output,outp); rewrite(output);
 read(n,m); dec(n);
 s:=0; pn:=0;
 tt:=trunc(sqrt(m));
 for i:=2 to tt do
  if m mod i=0 then
   begin
    inc(s);
    p[s]:=i;
    xar[s]:=0;
    while m mod i=0 do
     begin
      inc(xar[i]);
      m:=m div i;
     end;
   end;
 if m<>1 then begin inc(S); p[s]:=m; xar[s]:=1; end;
 for i:=0 to n do
  begin
   for j:=1 to s+1 do
    if j=s+1 then begin inc(pn);a[pn]:=i+1; end else
     if find(n,p[j])<xar[j]+find(i,p[j])+find(n-i,p[j]) then break;
  end;
 writeln(pn);
 for i:=1 to pn do write(a[i],' ');
 close(input); close(output);
end.
