{$APPTYPE CONSOLE}
var p,c,dm,ans,nd:array[1..100000] of longint;
    n,m,k,i,np,del,nans,nnd:longint;
    delm:boolean;
    
function decomp(n,sign:longint):boolean;
var i,min,max:longint;

begin
    i:=1;
    while p[i]*p[i]<=n do begin
        while n mod p[i] = 0 do begin
            c[i]:=c[i]+sign;
            n:=n div p[i];
        end;
        inc(i);
    end;
    if n<>1 then begin
        if n>110000 then begin writeln(0); halt; end;
        min:=1; max:=10000;
        while true do begin
            i:=(max+min) div 2;
            if p[i]=n then break;
            if p[i]>n then max:=i-1;
            if p[i]<n then min:=i+1;
        end;
        c[i]:=c[i]+sign;
    end;
end;

begin
    assign(input,'irrelevant.in');reset(input);
    assign(output,'irrelevant.out');rewrite(output);
    read(n,m);dec(n);
    if m=1 then begin
         writeln(n+1);
         for i:=1 to n+1 do write(i,' ');
         halt;
    end;

    p[1]:=2; np:=1;
    k:=3;
    while k<120000 do begin
        del:=3;
        while (del*del<k) and (k mod del <> 0) do inc(del,2);
        if del*del>k then begin
            inc(np);
            p[np]:=k;
        end;
        inc(k,2);
    end;

    decomp(m,1);
    for i:=1 to 10000 do begin
        dm[i]:=c[i];
        if dm[i]<>0 then begin
            inc(nnd);
            nd[nnd]:=i;
        end;
    end;
    fillchar(c,sizeof(c),0);

    for k:=1 to n do begin
        decomp(n+1-k,1);
        decomp(k,-1);
        delm:=true;
        i:=1;
        while i<=nnd do begin
            if c[nd[i]]<dm[nd[i]] then delm:=false;
            inc(i);
        end;

        if delm then begin
            inc(nans);
            ans[nans]:=k+1;
        end;

    end;
    writeln(nans);
    for i:=1 to nans do write(ans[i],' ');
end.
