{$APPTYPE CONSOLE}
program zzz;

var p,r:array[1..30]of longint;
i,j,n,m,c,pr:longint;
good:boolean;
ans:array[0..100000]of longint;

function f1(n,p:longint):longint;
var ans:longint;
pp:int64;
begin
ans:=0;
pp:=p;
while n>=pp do
 begin
  ans:=ans+n div pp;
  pp:=pp*p;
 end;
f1:=ans;
end;

function f(n,k,p:longint):longint;
begin
f:=f1(n,p)-f1(k,p)-f1(n-k,p);
end;

begin
assign(input,'irrelevant.in');reset(input);
assign(output,'irrelevant.out');rewrite(output);
read(n,m);
c:=0;
pr:=2;
while m>1 do
 begin
  if m mod pr=0 then
   begin
    inc(c);
    p[c]:=pr;r[c]:=0;
    while m mod pr=0 do
     begin
      inc(r[c]);
      m:=m div pr;
     end;
   end;
  inc(pr);
  if pr*pr>m then break;
 end;
if m>1 then begin inc(c);p[c]:=m;r[c]:=1;end;
for i:=1 to n do
begin
 good:=true;
 for j:=1 to c do if f(n-1,i-1,p[j])<r[j] then begin good:=false;break;end;
 if good then
   begin
    inc(ans[0]);
    ans[ans[0]]:=i;
   end;
end;
writeln(ans[0]);
for i:=1 to ans[0] do write(ans[i],' ');
close(input);
close(output);
end.