{$APPTYPE CONSOLE}
{.$R+}

type
  TPrimeDiv = array[1..32] of LongInt;

var
  N, M: LongInt;
  Num, Denom: TPrimeDiv;
  P: array[1..32] of Integer;
  C: array[1..32] of Integer;
  NP: Integer;

function AddPrime(W:Integer):Integer;
var
  I:Integer;
begin
  for I:=1 to NP do
    if (P[I] = W) then
      begin
        AddPrime:=I;
        Exit;
      end;
  Inc(NP);
  P[NP]:=W;
  AddPrime:=NP;
end;

procedure TestPrime(W: Integer);
var
  Ind: Integer;
begin
  if (M mod W = 0) then
    Ind:=AddPrime(W);
  while (M mod W = 0) do
    begin
      Inc(C[Ind]);
      M:=M div W;
    end;
end;

procedure Primes;
var
  I:Integer;
begin
  NP:=0;
  TestPrime(2);

  I:=3;
  repeat
    TestPrime(I);
    I:=I+2;
  until I*I > M;

  if (M > 1) then TestPrime(M);
end;

procedure FindDiv(A:Integer; var T: TPrimeDiv);
var
  I: Integer;
begin
  for I:=1 to NP do
    begin
      while (A mod P[I] = 0) do
        begin
          Inc(T[I]);
          A:=A div P[I];
        end;
    end;
end;

function Divides: Boolean;
var
  I:Integer;
begin
  Divides:=False;
  for I:=1 to NP do
    if (Num[I] - Denom[I] < C[I] ) then Exit;
  Divides:=True;
end;

var
  I:Integer;
  R: array[1..100000] of Integer;
  NR: Integer;

begin
  Assign(Input, 'irrelevant.in');
  Reset(Input);

  Assign(Output, 'irrelevant.out');
  ReWrite(Output);

  Read(N, M);
  Primes;
  FillChar(Num, Sizeof(Num), 0);
  FillChar(Denom, sizeof(Denom), 0);

  NR:=0;
  for I:=1 to N-1 do
    begin
      FindDiv(N-I, Num);
      FindDiv(I, Denom);

      if Divides then
        begin
          Inc(NR);
          R[NR]:=I+1;
        end;
    end;

  WriteLn(NR);
  for I:=1 to NR do
    Write(R[I], ' ');
  Writeln
end.
