{$A+,B-,C+,D+,E-,F-,G+,H+,I+,J-,K-,L+,M-,N+,O-,P+,Q-,R-,S-,T-,U-,V+,W-,X+,Y+,Z1}
{$MAXSTACKSIZE $3C00000}
{$APPTYPE CONSOLE}
const
 maxp = 100000;
type
 int = integer;
 real = extended;

var
 p : array[1..maxp] of boolean;
 st,k,pr,ans: array[0..100001] of int;
 i, j,t,ka,x : int;
 n,m: int;
 fl: boolean;

Function Get(x,n: int): int;
begin
Result := 0;
While n > 0 do
  begin
    n := n div x;
    inc(result,n); 
  end;
end;

begin
assign(input,'irrelevant.in');reset(input);
assign(Output,'irrelevant.out');rewrite(output);
FillChar(k,sizeof(k),0);
FillChar(st,sizeof(st),0);
FillChar(p,sizeof(p),true);
p[1] := false;
for i := 2 to maxp do
 if p[i] then
  for j := 2 to maxp div i do
   p[i * j] := false;
t := 0;
For i := 2 to 100000 do
  If p[i] Then
    begin
      inc(t);
      pr[t] := i;
    end;
Read(n,m);
For i := 1 to t do
  begin
    If m = 1 Then Break;
    While (m mod pr[i] = 0)and (m > 1) do
      begin
        inc(st[i]);
        m := m div pr[i];
      end;
  end;
If m > 1 Then
  begin
    Writeln(0);
    Halt
  end;
j := 0;
For i := 1 to t do
  If st[i] > 0 Then
    begin
      inc(j);
      pr[j] := pr[i];
      st[j] := st[i];
    end;
t := j;
ka := 0;
For i := 1 to t do k[i] := Get(pr[i],n-1);
For i := 0 to n-1 do
  begin
    fl := true;
    For j := 1 to t do
      begin
        x := k[j];
        x := x-Get(pr[j],i);
        x := x-Get(pr[j],n-i-1);
        fl := fl and (x > 0) and (x >= st[j])
      end;
    If fl Then
      begin
        inc(ka);
        ans[ka] := i+1;
      end;
  end;
Writeln(ka);
For i := 1 to ka do
  If i <> ka Then Write(ans[i],' ')
             Else Write(ans[i]);
end.
