{$APPTYPE CONSOLE}
{$O-,Q+,R+}

uses Math, SysUtils;

type
  int = integer;
  bool = boolean;
  real = extended;
var
  z, n, m, i, j, k, p : int;
  pf, pp : array[1..6] of int;
  fp : array[0..100000, 1..6] of int;
  a : array[1..100001] of int;
label next;
begin
  reset(input, 'irrelevant.in');
  rewrite(output, 'irrelevant.out');
  read(n, m);
  dec(n);
  p := 0;
  for i := 2 to trunc(sqrt(m)) do
    if m mod i = 0 then
    begin
      inc(p);
      pf[p] := i;
      pp[p] := 0;
      while m mod i = 0 do
      begin
        m := m div i;
        inc(pp[p]);
      end;
    end;
  if m <> 1 then
  begin
    inc(p);
    pf[p] := m;
    pp[p] := 1;
  end;

  for j := 1 to p do
    fp[0][j] := 0;
  for i := 1 to n do
  begin
    k := i;
    for j := 1 to p do
    begin
      fp[i][j] := fp[i - 1][j];
      while k mod pf[j] = 0 do
      begin
        inc(fp[i][j]);
        k := k div pf[j];
      end;
    end;
  end;
  z := 0;
  for i := 1 to n do
  begin
    for j := 1 to p do
      if fp[n][j] - fp[i][j] - fp[n - i][j] < pp[j] then
        goto next;
    inc(z);
    a[z] := i + 1;
  next:
  end;
  writeln(z);
  for i := 1 to z do
    write(a[i], ' ');
end.

