{$Q-,R-}
uses
  SysUtils;

var prime,C,next,mm:array[0..10000]of integer;
    pn,m,n,f1,f2,resnum,i,maxc,maxnext,maxmm:integer;
    res:array[1..100000]of integer;

function max(a,b:integer):integer;
begin
  if a>b
  then max:=a
  else max:=b
end;

procedure GenPrime;
var i,j:integer;
    f:boolean;
begin
  pn:=1;
  prime[1]:=2;
  for i:=2 to 100000 do
    begin
      j:=0;
      f:=true;
      repeat
        inc(j);
        if i mod prime[j]=0
        then f:=false;
      until (not f)or (j=pn) or (sqr(prime[j])>i);
      if f
      then begin
             inc(pn);
             prime[pn]:=i;
           end
    end;
end;

procedure Razlm(k:integer);
var i:integer;
begin
  fillchar(mm,sizeof(mm),0);
  i:=1;
  while k<>1 do
    begin
      while k mod prime[i]=0 do
        begin
          inc(mm[i]);
          k:=k div prime[i];
        end;
      inc(i)
    end;
  maxmm:=i-1;
end;

procedure Razl(k:integer);
var i:integer;
begin
  fillchar(next,sizeof(next),0);
  i:=1;
  while k<>1 do
    begin
      while k mod prime[i]=0 do
        begin
          inc(next[i]);
          k:=k div prime[i];
        end;
      inc(i)
    end;
  maxnext:=i-1
end;

procedure Add;
var i,x:integer;
begin
  x:=max(maxc,maxnext);
  for I:=1 to x do
    c[i]:=c[i]+next[i];
  maxc:=x;
end;

procedure Sub;
var i,x:integer;
begin
  x:=max(maxc,maxnext);
  for I:=1 to x do
    c[i]:=c[i]-next[i];
  maxc:=x
end;

function Compare:boolean;
var i,x:integer;
    f:boolean;
begin
  f:=true;
  x:=max(maxmm,maxc);
  I:=0;
  repeat
    inc(i);
    if c[i]<mm[i]
    then f:=false;
  until (not f)or(i=x);
  Compare:=f
end;

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

  readln(n,m);
  GenPrime;
  razlm(m);

  C[0]:=0;
  maxc:=0;
  f1:=n-1;
  f2:=1;
  resnum:=0;
  while f1>f2 do
    begin
      razl(f1);
      add;
      razl(f2);
      sub;
      if compare
      then begin
             inc(resnum);
             res[resnum]:=f2+1
           end;
      dec(f1);
      inc(f2)
    end;


  if resnum=0
  then writeln(0)
  else begin
         if (res[resnum]=((n div 2))+1)and(odd(n))
         then writeln(resnum*2-1)
         else writeln(resnum*2);
         for i:=1 to resnum do
           write(res[i],' ');
         if (res[resnum]=((n div 2))+1)and(odd(n))
         then dec(resnum);
         for i:=resnum downto 1 do
           write(n+1-res[i],' ');
       end;

{  if (not((n mod 2 = 1)and ((res[resnum])=(n div 2)+1)))
  then writeln(resnum*2)
  else writeln(resnum*2-1);
  for i:=1 to resnum-1 do
    write(res[i],' ');
  if (not((n mod 2 = 1)and ((res[resnum])=(n div 2)+1)))and(resnum>0)
  then write(res[resnum],' ');
  if resnum>0
  then for i:=resnum downto 1 do
         write(n+1-res[i],' ');}

  closefile(input);
  closefile(output);
end.
