{$apptype console}
var
 Ans,Mult,Cur,Primes,Pr:array[-100000..200000] of longint;
 a:array[1..200100] of boolean;
 p,i,j,k,s,pp,m,ss:longint;
 n:int64;


procedure Siete;
var
 i,k,s:longint;
 j:int64;
begin
  p:=0;
  fillchar(a,sizeof(a),0);
  for i:=2 to 100000 do
    begin
      if not a[i] then
        begin
          inc(p);
          primes[p]:=i;
          j:=i;
          while J<=n do
            begin
              a[j]:=true;
              j:=j+i;
            end;
        end;
    end;
end;

procedure generateMult;
var
  i,j,k:longint;
begin
  k:=m;
  fillchar(mult,sizeof(mult),0);
  for i:=1 to p do
    begin
       if k mod primes[i] = 0  then inc(s);
      repeat
        if k mod primes[i] <> 0  then break;
        k:= k div primes[i];
        inc(Mult[s]);
        Pr[s]:=primes[i];
      until false;
    end;
end;

procedure Checkadd(k:longint);
var
  i,j:longint;
begin
  for i:=1 to s do
    begin
      repeat
        if k mod Pr[i] <> 0  then break;
        k:= k div Pr[i];
        inc(Cur[i]);
        if (Cur[i]=Mult[i])and(Mult[i]>0) then dec(ss);
      until false;
    end;
end;

procedure Checkmin(k:longint);
var
  i,j:longint;
begin
  for i:=1 to s do
    begin
      if k=1 then break;
      repeat
        if k mod Pr[i] <> 0  then break;
        k:= k div Pr[i];
        dec(Cur[i]);
        if (Cur[i]=(Mult[i]-1))and(Mult[i]>0) then inc(ss);
      until false;
    end;
end;


begin
  assign(input,'irrelevant.in'); Reset(input);
  assign(output,'irrelevant.out'); Rewrite(output);
  fillchar(Ans,sizeof(ans),0);
  readln(n,m);
  Siete;
   generateMult;
  ss:=s;
  pp:=0;
  for i:=2 to n-1 do
   begin
      if (n-i+1)<>0 then
     Checkadd(n-i+1);
     Checkmin(i-1);
     if ss=0 then
       begin
         Ans[i]:=1;
         Ans[n-i+1]:=1;
       end;
   end;

  for i:=1 to n do
    if Ans[i]=1 then
      begin
        inc(pp);
        Ans[pp]:=i;
      end;
  writeln(pp);
  for i:=1 to pp do
   begin
     write(Ans[i],' ');
   end;
   Close(input);
   Close(output);
end.
