{$APPTYPE CONSOLE}

{$Q+,R+,S+}
const
    _fin='irrelevant.in';
    _fout='irrelevant.out';
    MAXN=100001;
    MAXMN=100000;

var c,cc,i,n,m:longint;
    a:array[0..MAXN] of longint;
    mn:array[1..maxmn,1..2] of longint; 
    was:boolean;

procedure fact;
var mm,i:longint;
begin
    c:=0;
    mm:=m;
    for i:=2 to trunc(sqrt(m)+1) do
        if mm mod i=0 then
        begin
            inc(c);
            mn[c,1]:=i;
            mn[c,2]:=0;
            while mm mod i=0 do
            begin
                inc(mn[c,2]);
                mm:=mm div i;
            end;
        end;
    if mm>1 then
    begin
        inc(c);
        mn[c,1]:=mm;
        mn[c,2]:=1;
    end;
end;
function count(a,b:longint):int64;
var t,aa:int64;
    res:int64;
begin
    t:=b;
    aa:=a;
    res:=0;
    while t<=aa do
    begin
        res:=res+(aa div t);
        t:=t*b;
    end;
    count:=res;
end;

procedure process;
var j,i:longint;
    aa,bb:int64;
    z:boolean;
begin
    fact;
    cc:=0;
    for i:=0 to n-1 do
    begin
        z:=true;
        for j:=1 to c do
        begin
            aa:=count(n-1,mn[j,1]);
            bb:=count(i,mn[j,1])+count(n-i-1,mn[j,1]);
            if (aa-bb)<mn[j,2] then begin z:=false;break;end;
        end;
        if z then begin
            inc(cc);
            a[i]:=0;
        end else a[i]:=1;
    end;
end;
begin
    assign(input,_fin);reset(input);
    read(n,m);
    close(input);
    process;
    assign(output,_fout);rewrite(output);
    writeln(cc);
    was:=false;
    for i:=0 to n-1 do
    begin
        if a[i]=0 then begin
          if was then write(' ') else was:=true;
            write(i+1);
        end;
    end;
    writeln;
    close(output);
end.