{$A+,B-,C+,D+,E-,F-,G+,H+,I+,J-,K-,L+,M-,N+,O+,P+,Q+,R+,S-,T-,U-,V+,W-,X+,Y+,Z1}

const
  cinfile = 'irrelevant.in';
  coutfile = 'irrelevant.out';

  nmax = 110000;

type
  int = longint;
  real = extended;
  float = extended;

  trec = record
           p, k : int;
         end;

var
  n, k, m : int;
  ans : int;

  kp : int;
  p : array [1..20] of trec;
  me : array [1..20] of int;
  res: array [0..nmax] of int;

procedure outdata;
var
  i, j : int;
begin
  writeln(ans);
  for i:= 1 to ans - 1 do writeln(res[i],' ');
  if ans <> 0 then writeln(res[ans]);
end;

procedure go(c : int; d : int);
var
  i : int;
begin
  for i:= 1 to kp do
    while c mod p[i].p = 0 do
    begin
      inc(me[i], d);
      c:= c div p[i].p;
    end;
end;

procedure solve;
var
  i, j : int;
  ok : boolean;
begin
  i:= 2;
  kp:= 0;
  while (i*i <= m) do
  begin
    if m mod i = 0 then
    begin
      inc(kp);
      p[kp].p:= i;
      p[kp].k:= 0;
      while m mod i = 0 do
      begin
        inc(p[kp].k);
        m:= m div i;
      end;
    end;
    inc(i);
  end;
  if m <> 1 then
  begin
    inc(kp);
    p[kp].p:= m;
    p[kp].k:= 1;
  end;

  fillchar(me, sizeof(me), 0);
  ans:= 0;
  for i:= 0 to n-2 do
  begin
    go(n-i-1, +1);
    go(i + 1, -1);
    ok:= true;
    for j:= 1 to kp do
      if me[j] < p[j].k then ok:= false;
    if ok then
    begin
      inc(ans);
      res[ans]:= i + 2;
    end;
  end;
end;

procedure readdata;
var
  i, j : int;
begin
  read(n, m);
end;

begin
  reset(input, cinfile);
  rewrite(output, coutfile);
  readdata;
  solve;
  outdata;
  close(output);
  close(input);
end.
