{$A+,B-,C+,D+,E-,F-,G+,H+,I+,J-,K-,L+,M-,N+,O+,P+,Q-,R+,S-,T-,U-,V+,W-,X+,Y+,Z1}
{$MINSTACKSIZE $00004000}
{$MAXSTACKSIZE $00100000}
{$IMAGEBASE $00400000}
{$APPTYPE CONSOLE}

var qc,he:array[0..200000]of int64;
    b:array[0..200000]of boolean;
    p:array[1..50000,1..2]of longint;
    res,cur,q,c,x,y:int64;
    k,pp,i,j,n,m:longint;
    ass:boolean;
begin
assign(input,'irrelevant.in');
assign(output,'irrelevant.out');
reset(input);
rewrite(output);
readln(n,m);
pp:=0;
for i:=2 to 50000 do
        begin
        if m mod i=0 then
                begin
                inc(pp);
                p[pp,1]:=i;
                end;
        while m mod i = 0 do
                begin
                inc(p[pp,2]);
                m:=m div i;
                end;
        end;
if m>1 then
        begin
        inc(pp);
        p[pp,1]:=m;
        p[pp,2]:=1;
        end;
qc[0]:=1;
for i:=1 to n-1 do b[i]:=true;
for k:=1 to pp do
begin
fillchar(he,sizeof(he),0);
fillchar(qc,sizeof(qc),0);
ass:=false;
m:=p[k,1];
qc[0]:=1;
he[0]:=0;
for i:=1 to n do
        begin
        qc[i]:=qc[i-1]*i;
        he[i]:=he[i-1];
        while qc[i] mod m = 0 do
                begin
                qc[i]:=qc[i] div m;
                inc(he[i]);
                end;
        qc[i]:=qc[i] mod m;
        end;
x:=he[n-1];
for i:=1 to n-2 do
        begin
        q:=he[i];
        c:=he[n-1-i];
        y:=q+c;
        cur:=qc[i]*qc[n-i];
        while ((cur mod m) = 0) do
                begin
                cur:=cur div m;
                inc(y);
                end;
        if x<y+p[k,2] then b[i+1]:=false;
        end;
end;
for i:=2 to n-1 do
if b[i] then
        begin
        inc(res);
        end;
writeln(res);
for i:=2 to n-1 do if b[i] then write(i,' ');
end.
