program taskI;
{$APPTYPE CONSOLE}

type pairs = record
  d : integer;
  count : integer;
  end;

var z,i,j,n,k,m,m0 : integer;
    d : array of pairs;
    res : array of pairs;
    ir : array of integer;
    kol : integer;
    up,down : integer;
    f:textfile;
    good : boolean;

begin
  AssignFile(f,'irrelevant.in'); reset(f);
  readln(f,n,m0);
  CloseFile(f);

  AssignFile(f,'irrelevant.out'); Rewrite(f);

  m:=m0;

  i := 2; SetLength(d,0); k:=0;
  repeat
    if m mod i=0 then
      begin
      inc(k);
      SetLength(d,k); d[k-1].d:=i; d[k-1].count:=0;

      while m mod i=0 do
        begin
          inc(d[k-1].count);
          m := m div i;
        end;

      end;
    inc(i);
  until m=1;

{  for i:=0 to k-1 do
    writeln(f,d[i].d);}

  SetLength(res,k);
  for i:=0 to k-1 do
    begin
      res[i].d:=d[i].d;
      res[i].count:=-d[i].count;
    end;

  kol:=0; SetLength(ir,kol);

  if (d[k-1].d<n) and (n>2) then
    begin
    up := n-1; down := 1;
    for i:=2 to n-1 do
      begin
        z := up;
        for j:=0 to k-1 do
          while z mod d[j].d=0 do
            begin
            inc (res[j].count);
            z := z div d[j].d;
            end;

        z := down;
        for j:=0 to k-1 do
          while z mod d[j].d=0 do
            begin
            dec (res[j].count);
            z := z div d[j].d;
            end;

        dec(up); inc(down);
        good:=true;
        for j:=0 to k-1 do
          good:=good and (res[j].count>=0);

        if good then
          begin
          inc (kol); SetLength (ir,kol);
          ir[kol-1]:=down;
          end;
      end;
    end;

  writeln (f,kol);
  for i:=0 to kol-1 do
    write(f,ir[i],' ');

  CloseFile(f);
end.
