program blank;
{$o-,P+,Q+,R+}
{$APPTYPE CONSOLE}

uses
  SysUtils;
const
  taskid='irrelevant';
  infile=taskid+'.in';
  outfile=taskid+'.out';
  maxm=200000;
var
   flag:array [1..maxm] of boolean;
   pr:array [1..maxm] of longint;
   n,m,k,len:longint;
   mas:array [1..100] of longint;
   mas_count,my_count,digit:array [1..100] of longint;
   out:array [0..100000] of longint;
{--------------------------------------------------------------------}
Procedure Init;
var
  i:longint;
  J:INT64;
Begin
  fillchar(flag,sizeof(flag),false);
  flag[1]:=true;
  len:=0;
  for i:=2 to maxm do
    if flag[i]=false then begin
      inc(len);
      pr[len]:=i;
      j:=int64(i)*i;
      while (j<=maxm) do begin
        flag[j]:=true;
        j:=j+i;
      end;
    end;
end;
{--------------------------------------------------------------------}
Procedure Schet(a:longint);
var
  i:longint;
Begin
  fillchar(digit,sizeof(digit),0);
  for i:=1 to k do begin
    while a mod mas[i] = 0 do begin
      a:= a div mas[i];
      inc(digit[i]);
    end;
    if a = 1 then break;
  end;
end;
{--------------------------------------------------------------------}
Procedure Lesen;
Begin
  read(n,m);
  n:=n-1;
end;
{--------------------------------------------------------------------}
Procedure Run;
var
  ta,i:longint;
Begin
  fillchar(mas,sizeof(mas),0);
  fillchar(mas_count,sizeof(mas_count),0);
  k:=0;
  ta:=m;
  for i:=1 to len do
    if ta mod pr[i] = 0 then begin
      inc(k);
      mas[k]:=pr[i];
      while ta mod mas[k] = 0 do begin
        ta:=ta div mas[k];
        inc(mas_count[k]);
      end;
    end;
  if ta<>1 then begin
    inc(k);
    mas[k]:=ta;
    mas_count[k]:=1;
  end;
end;
{--------------------------------------------------------------------}
Procedure Schriben;
var
  i,j:longint;
  ok:boolean;
begin
  fillchar(my_count,sizeof(my_count),0);
  for i:=0 to n-1 do begin
    schet(n-i);
    for j:=1 to k do
      inc(my_count[j],digit[j]);
    schet(i+1);
    ok:=true;
    for j:=1 to k do begin
      dec(my_count[j],digit[j]);
      if mas_count[j]>my_count[j] then begin
        ok:=false;
      end;
    end;
    if ok then begin
      inc(out[0]);
      out[out[0]]:=i+2;
    end;
  end;
  writeln(out[0]);
  for i:=1 to out[0] do
    write(out[i],' ');
end;
{--------------------------------------------------------------------}
Procedure Schriben_false;
var
  i:longint;
begin
  writeln(n+1);
  for i:=1 to n+1 do
    write(i,' ');
end;
{--------------------------------------------------------------------}
begin
  assign(input,infile);  reset(input);
  assign(output,outfile);  rewrite(output);
  Lesen;
  if m<>1 then begin
    Init;
    Run;
    Schriben;
  end;
  close(input);  close(output);
end.
