{$apptype console}

var
//  p: array [2..100000] of integer;
  pp, pk: array [1..50] of integer;
  pc: integer;
  m, n, i, j: integer;
  irr: array[0..100000] of boolean;
  ic: integer;

  function getK(N, P: integer): integer;
  var
    t: integer;
  begin
    t := P;
    Result := 0;
    while (P <= N) do begin
      Inc(Result, N div P);
      P := P * t;
    end;
  end;

begin
  Assign(input, 'irrelevant.in');
  Assign(output, 'irrelevant.out');
//  FillChar(pp, SizeOf(pp), 0);
//  FillChar(pp, SizeOf(pp), 0);
  Reset(input);
  Rewrite(output);
  Read(n, m);
  i := 2;
  pc := 0;
  while (m > 1) and (i <= n) do begin
    if (m mod i = 0) then begin
      Inc(pc);
      pp[pc] := i;
      pk[pc] := 0;
      repeat
        Inc(pk[pc]);
        m := m div i;
      until (m mod i <> 0);
    end;
    Inc(i);
  end;
  if (pc = 0) then begin
    Writeln(0);
    Exit;
  end;
  for i := 0 to n - 1 do begin
    irr[i] := true;
    for j := 1 to pc do
      if
        (getK(n - 1, pp[j]) - getK(n - i - 1, pp[j]) - getK(i, pp[j]) < pk[j])
      then begin
        irr[i] := false;
        Break;
      end;
  end;
  ic := 0;
  for i := 0 to n - 1 do
    if irr[i] then
      Inc(ic);
  Writeln(ic);
  for i := 0 to n - 1 do
    if irr[i] then
      Write(i + 1, ' ');
  Close(input);
  Close(output);
end.
