program ProblemI;

{$APPTYPE CONSOLE}

const
    MAXN = 100000;

type
  TPrs = array [1..MaxN] of integer;

var
    c: array[1..MAXN] of boolean;
    p, pm, pk, pck, pmi: TPrs;
    cp, cmi: integer;

procedure make(m: integer; var pp: TPrs);
var
    i: integer;
begin
  FillChar(pp, SizeOf(pp), 0);
  for i := 1 to cmi do
  while (m mod p[pmi[i]] = 0) do begin
    inc(pp[pmi[i]]);
    m := m div p[pmi[i]]
  end;
end;

function makem(m: integer; var pp: TPrs): integer;
var
  i: integer;
begin
  FillChar(pp, SizeOf(pp), 0);
  for i := 1 to cp do
  while (m mod p[i] = 0) do begin
    inc(pp[i]);
    m := m div p[i]
  end;
  result := m;
end;

var
  i, j, k, n, m, solcount: integer;
  sol: array [1..MaxN] of integer;
  flag: boolean;

begin
  c[1] := false;
  c[2] := false;
  cp := 1;
  p[1] := 2;
  for i := 2 to MAXN do begin
    if (i and 1 = 1)and(not c[i]) then begin
      j := i + i;
      while j <= MAXN do begin
        c[j] := true;
        inc(j, i)
      end;
      inc(cp);
      p[cp] := i;
    end
  end;
  assign(input, 'irrelevant.in');
  reset(input);
  assign(output, 'irrelevant.out');
  rewrite(output);
  read(n, m);
  if makem(m, pm) > 1 then
  begin
    writeln(0);
    exit;
  end;
  cmi := 0;
  for i := 1 to cp do
  if pm[i] > 0 then
  begin
    inc(cmi);
    pmi[cmi] := i;
  end;
  solcount := 0;
  for k := 1 to n - 2 do
  begin
    make(n - k, pk);
    for i := 1 to cmi do
    if pk[pmi[i]] > 0 then
      inc(pck[pmi[i]], pk[pmi[i]]);
    make(k, pk);
    flag := false;
    for i := 1 to cmi do
    begin
      if pk[pmi[i]] > 0 then
        dec(pck[pmi[i]], pk[pmi[i]]);
      if pck[pmi[i]] < pm[pmi[i]] then
        flag := true;
    end;
    if not flag then
    begin
      inc(solcount);
      sol[solcount] := k + 1;
    end;
  end;
  writeln(solcount);
  for i := 1 to solcount do
    write(sol[i], ' ');
end.
