{.$define debug}

{$apptype console}

{$ifdef debug}
{$R+,S+,Q+,I+,O-}
{$else}
{$R+,S-,Q+,I-,O+}
{$endif}

{$assertions on}
{$apptype console}

program template;
uses
 SysUtils;
const
 kmax = 30;
 lmax = 110000;
 {$ifdef debug}
 cinfile = 'input.txt';
 coutfile = 'output.txt';
 {$else}
 cinfile = 'irrelevant.in';
 coutfile = 'irrelevant.out';
 {$endif}
type
 int = longint;
 real = extended;
 tPrime = record
  p :int;
  alpha :int;
 end;
var
 n :int;
 m :int;
 primes :array [1..kmax] of tPrime;
 k :int;
 results :array [0..lmax] of boolean;
 ans :int;

procedure init;
begin
 fillchar (n,integer(@ans) - integer(@n),0);
 ans := 0;
end;

procedure readdata;
var i,j :int;
begin
 assign (input,cinfile);
 reset (input);
 read (n,m);
 close (input);
end;

procedure outdata;
var i,j :int;
begin
 assign (output,coutfile);
 rewrite (output);
 writeln (ans);
 for i := 1 to n do
  if results[i] then
   writeln (i);
 close (output);
end;

function getFact (fact :int; divisor :int):int;
var cur :int;
begin
 result := 0;
 cur := divisor;
 while (fact div cur > 0) do
  begin
   result := result + (fact div cur);
   cur := cur * divisor;
  end;
end;

function test (v :int):boolean;
var i :int;
    power :int;
begin
 test := false;
 for i := 1 to k do
  begin
   power := getFact (n-1,primes[i].p) - getFact (v-1,primes[i].p) -
    getFact (n-v,primes[i].p);
   if power < primes[i].alpha then
    exit;
  end;
 test := true;  
end;

procedure solve;
var i,j :int;
    cur :int;
begin
 if n = 1 then
  begin
   ans := 0;
   exit;
  end;
 cur := m;
 for i := 2 to trunc(sqrt(m)) do
  begin
   if (cur mod i = 0) then
    begin
     inc (k);
     primes[k].p := i;
     primes[k].alpha := 0;
     while cur mod i = 0 do
      begin
       inc (primes[k].alpha);
       cur := cur div i;
      end;
     if cur = 1 then
      break;
    end;
  end;
 if cur <> 1 then
  begin
   inc (k);
   primes[k].p := cur;
   primes[k].alpha := 1;
  end;
 for i := 1 to n do
  if test(i) then
   begin
    results[i] := true;
    inc (ans);
   end; 
end;

begin
 init;
 readdata;
 solve;
 outdata;
end.
