program zi1;

{$APPTYPE CONSOLE}

uses
  SysUtils,math;

var
  mlen:integer;
  mp: array[1..60,0..1] of integer;
  ap: array[1..60] of integer;
  primes: array[1..10000] of integer;
  s: integer;
  nprimes: integer = 0;
  f: boolean;
  b:array of boolean;
  n,i,j,k:integer;
  m:integer;
  mmm: array [1..10000] of integer;
  x,y:integer;
begin
  for i := 2 to 100000 do
    begin
      s := round(sqrt(i));
      f := true;
      for j := 1 to nprimes do
        begin
          if j > s then break;
          if i mod primes[j] = 0 then begin f := false; break; end;
        end;
      if f then
        begin
          inc(nprimes);
          primes[nprimes] := i;
        end;
    end;
  assign(input,'irrelevant.in');
  reset(input);
  assign(output,'irrelevant.out');
  rewrite(output);
  readln(n,m);
  setlength(b,n);
  fillchar(mmm,sizeof(mmm),0);
  mlen := 0;
  for i := 1 to nprimes do
    begin
      j := m;
      while j mod primes[i] = 0 do
        begin
          j := j div primes[i];
          inc(mmm[i]);
        end;
      if mmm[i]<>0 then
        begin
          inc(mlen);
          mp[mlen][0] := primes[i];
          mp[mlen][1] := mmm[i];
        end;
    end;
  fillchar(ap,sizeof(ap),0);
  j:=0;
  for i:= 0 to n-1 do b[i]:=false;
  for i:= 1 to n-1 do begin
    x := n-i;
    y := i;
    f := true;
    for k := 1 to mlen do
      begin
        while x mod mp[k][0]=0 do
          begin inc(ap[k]); x := x div mp[k][0]; end;
        while y mod mp[k][0]=0 do
          begin dec(ap[k]); y := y div mp[k][0]; end;
        if ap[k]<mp[k][1] then f := false;
      end;
//    a[i]:=((a[i-1]*(n-i))div(i));
    if f then begin b[i]:=true; inc(j);end;
  end;
  writeln(j);
  for i:= 0 to n-1 do

    if b[i] then begin dec(j);if j> 0 then write(i+1,' ')
                              else write(i+1);
  end;
end.
 