program iii;

{$APPTYPE CONSOLE}

uses
  SysUtils;

type d=record
         pr:array [1..66] of longint;
         kpr:array [1..10] of longint;
       end;
var n,m,i,size,ndop,nst:longint;
  dpr:array [1..10] of longint;
  pr:array [1..66] of longint;
  f:array [0..100000] of d;
  mas:d;
  st:array [1..100000] of longint;
procedure prime;
var i,j,sq:longint;
  p:boolean;
begin
  pr[1]:=2;
  size:=1;
  i:=3;
  sq:=trunc(sqrt(100000))+1;
  while i<=sq do begin
    p:=true;
    for j:=1 to size do
      if i mod pr[j]=0 then begin
        p:=false;
        break;
      end;
    if p then begin
      inc(size);
      pr[size]:=i;
    end;
    i:=i+2;
  end;
end;
procedure factorize(m:longint);
var i,j:longint;
  p:boolean;
begin
  for i:=1 to size do
    while m mod pr[i]=0 do begin
        inc(mas.pr[i]);
        m:=m div pr[i];
    end;
  ndop:=0;
  i:=sqr(pr[size])+2;
  while m<>1 do begin
    p:=true;
    for j:=3 to trunc(sqrt(i))+1 do
      if i mod j=0 then begin
        p:=false;
        break;
      end;
    if p then
        if m mod i=0 then begin
          inc(ndop);
          dpr[ndop]:=i;
          while m mod i=0 do begin
            inc(mas.kpr[ndop]);
            m:=m div i;
          end;
        end;
    i:=i+2;
  end;
end;
procedure fact(n:longint);
var i,m:longint;
begin
  m:=n;
  for i:=1 to size do
    f[m].pr[i]:=f[m-1].pr[i];
  for i:=1 to ndop do
    f[m].kpr[i]:=f[m-1].kpr[i];
  for i:=1 to size do
    while (n mod pr[i]=0) and (n<>1) do begin
      inc(f[m].pr[i]);
      n:=n div pr[i];
    end;
  for i:=1 to ndop do
    while (n mod dpr[i]=0) and (n<>1) do begin
      inc(f[m].kpr[i]);
      n:=n div dpr[i];
    end;
end;
procedure divis(i:longint);
var p:boolean;
  j:longint;
begin
  p:=true;
  for j:=1 to size do
    if f[n-1].pr[j]-f[i].pr[j]-f[n-1-i].pr[j]<mas.pr[j] then begin
      p:=false;
      break;
    end;
  if p then
    for j:=1 to ndop do
      if f[n-1].kpr[j]-f[i].kpr[j]-f[n-1-i].kpr[j]<mas.kpr[j] then begin
        p:=false;
        break;
      end;
  if p then begin
    inc(nst);
    st[nst]:=i+1;
  end;
end;
begin
  assign(input,'irrelevant.in'); reset(input);
  assign(output,'irrelevant.out'); rewrite(output);
  fillchar(pr,sizeof(pr),0);
  fillchar(f,sizeof(f),0);
  prime;
  read(n,m);
  factorize(m);
  for i:=2 to 100000 do
    fact(i);
  nst:=0;
  for i:=0 to n-1 do
    divis(i);
  writeln(nst);
  for i:=1 to nst do
    write(st[i],' ');
  close(input); close(output);
end.
