{$o-,q+,r+}
{ $o+,q-,r-}
{$MINSTACKSIZE $00004000}
{$APPTYPE console}
uses
    sysutils;
type
    int = longint;
const
    finname = 'irrelevant';
var
    n, m, i, k: int;
    f: int64;
begin
    reset(input, finname + '.in');
    rewrite(output, finname + '.out');
    read(n, m);
    dec(n);
    k := 0;
    for i := 0 to n do begin
        f := int64(i) * int64(n - i) + 1;
        if f mod int64(m) = 0 then
            inc(k);
    end;
    writeln(k);
    for i := 0 to n do begin
        f := int64(i) * int64(n - i) + 1;
        if f mod int64(m) = 0 then
            write(i + 1, ' ');
    end;
end.