const maxn=100000;

var cnt,n,m,k:longint;
    ok:array[0..maxn]of boolean;
    prs,nprs:longint;
    sp,nsp,x,xm:array[1..maxn]of longint;
    ispr:array[1..maxn]of boolean;
    ex:boolean;

procedure getpr;
var i,j:longint;
begin
  prs:=0;
  fillchar(ispr,sizeof(ispr),true);
  for i:=2 to maxn do
    if ispr[i] then
      begin
        inc(prs);
        sp[prs]:=i;
        j:=2*i;
        while (j<=maxn) do
          begin
            ispr[j]:=false;
            j:=j+i;
          end;
      end;
end;

procedure getm;
var i:longint;
begin
  fillchar(xm,sizeof(xm),0);
  nprs:=0;
  for i:=1 to prs do
    if m mod sp[i]=0 then
      begin
        inc(nprs);
        nsp[nprs]:=sp[i];
        while m mod sp[i]=0 do
          begin
            inc(xm[nprs]);
            m:=m div sp[i];
          end;
      end;
  if m=1 then
    ex:=true
  else
    ex:=false;
end;

procedure dok;
var i,j:longint;
begin
  j:=k+1;
  if j=0 then
    exit;
  for i:=1 to nprs do
    while j mod nsp[i]=0 do
      begin
        dec(x[i]);
        j:=j div nsp[i];
      end;
end;

procedure donk1;
var i,j:longint;
begin
  j:=n-k-1;
  if j=0 then
    exit;
  for i:=1 to nprs do
    while j mod nsp[i]=0 do
      begin
        inc(x[i]);
        j:=j div nsp[i];
      end;
end;

function check:boolean;
var i:longint;
begin
  check:=false;
  for i:=1 to nprs do
    if x[i]<xm[i] then
      exit;
  check:=true;
end;

begin
  assign(input,'irrelevant.in');
  reset(input);
  assign(output,'irrelevant.out');
  rewrite(output);

  read(n,m);
  getpr;
  getm;

  cnt:=0;
  fillchar(x,sizeof(x),0);
  fillchar(ok,sizeof(ok),false);
  if ex then
    begin
      for k:=0 to n-1 do
        begin
          if check then
            begin
              ok[k]:=true;
              inc(cnt);
            end;
          dok;
          donk1;
        end;
    end;

  writeln(cnt);
  for k:=0 to n-1 do
    if ok[k] then
      write(k+1,' ');

  close(input);
  close(output);
end.