program big;

{$APPTYPE CONSOLE}

uses
  SysUtils;
const
 base=10000;
 base_c=6;
var
 ch: array of longword;
procedure mul(x: Integer);
var
 i,dop,plus: Integer;
 res: Int64;
begin
 dop:=0;
 plus:=0;
 for i:=Low(ch) to high(ch) do begin
   res:=ch[i]*x;
   if res > base then begin
        ch[i]:=res mod base;
        dop:= res div base;
   end else
      ch[i]:=res;
   ch[i]:=ch[i]+plus;
   plus:=dop;
 end;
 if plus>0 then begin
   SetLength(ch,Length(ch)+1);
   ch[high(ch)]:=plus;
 end;
end;
procedure del(x: Integer);
var
 i: Integer;
 ost: Integer;
begin
 ost := 0;
 for i:=high(ch) downto low(ch) do begin
   ost:=  (ch[i]+ost*base) mod x;
   ch[i]:= (ch[i]+ost*base) div x;
 end;
end;

function ost9(x: Integer): Integer;
var
 i: Integer;
 ost: integer;
begin
  ost := 0;
  for i := high(ch) downto low(ch) do begin
    ost := (ost * base + ch[i]) mod x;
  end;
  result := ost;
end;

var
 n,i,m: Integer;
 mas: array of integer;
begin
 assign(input, 'irrelevant.in');
 assign(output, 'irrelevant.out');
 reset(input);
 rewrite(output);
Readln(n,m);
setlength(mas,0);
SetLength(ch,1);
ch[0] := 1;
for i := 1 to n-1 do
  begin
    mul(n-i);
    del(i);
    if (ost9(m) = 0) then begin setlength(mas, length(mas)+1); mas[high(mas)] := i end;
  end;
writeln(length(mas)); for i := 0 to high(mas) do begin write(mas[i]+1, ' '); end;
close(input);
close(output);
end.
