program i2;

{$APPTYPE CONSOLE}

uses
  SysUtils;

type longint = cardinal;

var
  n,m:longint;
  var a,b,c:array[0..50] of longint;
  d:array[1..100002] of boolean;
  i,j:longint;
  flag:boolean;
  mmm,ddd,kolvo:longint;

begin
  { TODO -oUser -cConsole Main : Insert code here }
    assign(input,'irrelevant.in');
  assign(output,'irrelevant.out');
  reset(input);
  rewrite(output);


  read(n,m);
  fillchar(a,sizeof(a),0);
  fillchar(b,sizeof(b),0);
  fillchar(c,sizeof(c),0);
  fillchar(d,sizeof(d),0);

  for i:=2 to 1000000 do
    begin
      if m mod i = 0 then
        begin
          inc(a[0]);
          b[a[0]]:=i;
          while m mod i = 0 do begin
            inc(a[a[0]]);
            m:=m div i;
          end;
        end;
    end;
  mmm:=1;
  ddd:=1;
  for j:=1 to n do
    begin
      for i:=1 to a[0] do
        begin
           while mmm mod b[i] = 0 do
             begin
               inc(c[i]);
               mmm:=mmm div b[i];
             end;
        end;
      for i:=1 to a[0] do
        begin
           while ddd mod b[i] = 0 do
             begin
               dec(c[i]);
               ddd:=ddd div b[i];
             end;
        end;

      flag:=false;
      for i:=1 to a[0] do
        if c[i]<a[i] then flag:=true;
      if (flag=false) and (a[0]>0) then d[j]:=true;
      mmm:=n-j;
      ddd:=j;
    end;

  kolvo:=0;
  for i:=1 to n do
      if d[i] then inc(kolvo);

  writeln(kolvo);
  for i:=1 to n+1 do
    if d[i] then write(i,' ');

close(input);
close(output);

end.
