program Iggg;

{$APPTYPE CONSOLE}

uses
  SysUtils;

Var N,M                 : longint;
    i,NA,NP,k           : longint;
    j                   : Int64;
    P,Nocc,Diff         : array [1..50] of Int64;
    A                   : array [1..1000000] of longint;
    all_fine            : boolean;

Function StepMFact(X,Ma : Int64) : Int64;
Var Ans, CurStep : Int64;
Begin
  Ans:=0; CurStep:=Ma;
  While true do Begin
    Ans:=Ans+(X div CurStep);
    If (X div Ma)<CurStep then Break;
    CurStep:=CurStep*Ma;
  End;

  StepMFact:=Ans;
End;

begin
  { TODO -oUser -cConsole Main : Insert code here }
  AssignFile(input, 'irrelevant.in'); Reset(Input);
  AssignFile(output, 'irrelevant.out'); Rewrite(Output);

  Read(N,M);

  NP:=0;
  For i:=2 to 100 do
  if (M mod i)=0 then Begin
    Inc(NP); P[NP]:=i;
    Nocc[NP]:=0;
    While (M mod i)=0 do Begin
      Inc(Nocc[NP]);
      M:=M div i;
    End;
  End;

  If (N<3) OR (M>1) then Begin
    Writeln(0);
    close(input); close(output);
    Halt(0);
  End;

  NA:=0;
  For i:=0 to N-1 do Begin
    For k:=1 to NP do
    Diff[k]:=StepMFact(N-1,P[k])-StepMFact(i,P[k])-StepMFact(N-1-i,P[k]);

    all_fine:=true;
    For k:=1 to NP do
    all_fine:=all_fine AND (Diff[k]>=Nocc[k]);

    IF All_Fine then Begin
      Inc(NA); A[NA]:=i+1;
    End;
  End;

  Writeln(NA);
  For i:=1 to NA do Write(A[i],' ');
  close(input); close(output);
end.
