program pi;

const infile  = 'irrelevant.in';
      outfile = 'irrelevant.out';
      maxn    = 100000;

var n, m, p : longint;
    prime : array[1..32]of record p, cnt : longint end;
    num : array[1..32]of longint;
    den : array[0..maxn, 1..32]of longint;
    ok : array[0..maxn]of byte;

procedure init;
 begin
  assign(input, infile); reset(input);
  assign(output, outfile); rewrite(output);
  read(n, m);
 end;

function count(n, prime : longint) : longint;
var i : longint;
 begin
  i := 0;
  while (n mod prime = 0) and (n > 0) do begin
    i := i + 1;
    n := n div prime;
   end;
  count := i;
 end;

procedure solve;
var i, j, a : longint;
 begin
  p := 0;
  i := 2;
  while i * i <= m do begin
    if m mod i = 0 then begin
      p := p + 1;
      prime[p].p := i;
      prime[p].cnt := 0;
      while m mod i = 0 do begin
        inc(prime[p].cnt);
        m := m div i;
       end;
     end;
    i := i + 1; 
   end;
  if m > 1 then begin
    p := p + 1;
    prime[p].p := m;
    prime[p].cnt := 1;
   end; 
  for i := 1 to p do num[i] := count(n - 1, prime[i].p);
  for i := 1 to p do den[0, i] := num[i];
  for i := 1 to n - 1 do
   for j := 1 to p do den[i, j] := den[i - 1, j] + count(i, prime[j].p) - count(n - i, prime[j].p);
  fillchar(ok, sizeof(ok), 0);
  a := 0;
  for i := 0 to n - 1 do begin
    ok[i] := 1;
    for j := 1 to p do if num[j] - den[i, j] < prime[j].cnt then ok[i] := 0;
    a := a + ok[i];
   end;
  writeln(a); 
  for i := 0 to n - 1 do if ok[i] = 1 then write(i + 1, ' '); writeln;
 end;

procedure save;
 begin
  close(output);
 end;

begin
 init;
 solve;
 save;
end.