{$o-,q+,r+}
{ $o+,q-,r-}
{$MINSTACKSIZE $00004000}
{$APPTYPE console}
uses
    sysutils;
type
    int = longint;
const
    finname = 'irrelevant';
    maxpp = 50000;
    maxp = 50000;
var
    n, m, i, j, k: int;
    np, nq, na: int;
    u: array[1 .. maxpp] of boolean;
    a, p, q, dd, dq: array[1 .. maxp] of int;
begin
    reset(input, finname + '.in');
    rewrite(output, finname + '.out');
    read(n, m);
    dec(n);

    np := 0;
    for i := 1 to maxpp do
        u[i] := false;
    for i := 2 to maxpp do begin
        if u[i] then
            continue;
        inc(np);
        p[np] := i;
        j := 2 * i;
        while (j <= maxpp) do begin
            u[j] := true;
            inc(j, i);
        end;
    end;

    nq := 0;
    for i := 1 to np do begin
        if (m mod p[i] > 0) then
            continue;
        inc(nq);
        dq[nq] := 0;
        q[nq] := p[i];
        while (m mod p[i] = 0) do begin
            inc(dq[nq]);
            m := m div p[i];
        end;
    end;

    for i := 1 to nq do
        dd[i] := 0;

    na := 0;

    for i := 1 to n - 1  do begin
        j := n - i + 1;
        for k := 1 to nq do
            while (j mod q[k] = 0) do begin
                inc(dd[k]);
                j := j div q[k];
            end;
        j := i;
        for k := 1 to nq do
            while (j mod q[k] = 0) do begin
                dec(dd[k]);
                j := j div q[k];
            end;
        j := 1;
        for k := 1 to nq do
            if (dd[k] < dq[k]) then begin
                j := 0;
                break;
            end;
        if (j = 0) then
            continue;
        inc(na);
        a[na] := i;
    end;
    writeln(na);
    for i := 1 to na do
        write(a[i] + 1, ' ');
end.