{$DEFINE DEBUG}

{$IFDEF DEBUG}
{$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}
{$ELSE}
{$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}
{$ENDIF}

{$MINSTACKSIZE $00004000}
{$MAXSTACKSIZE $02000000}
{$APPTYPE CONSOLE}

uses
  Math, SysUtils;

type
  int = longint;
  float = extended;

const
  maxp = 100;
  maxn = 200000;
  cin_file = 'irrelevant.in';
  cout_file = 'irrelevant.out';
  eps : float = 1e-9;
  fmax : float = 1e40;
  besk = $3F3F3F3F;

type
  tfactor = record
    k : int;
    p, c : array[0..maxp] of int;
  end;

var
  n, m : int;
  mf : tfactor;
  ans : array[0..maxn] of int;

function countPr(n : int; p : int) : int;
begin
  ASSERT(p > 1);
  result := 0;
  while (n > 0) do
  begin
    n := n div p;
    inc(result, n);
  end;
end;

function isGood(n, k : int) : boolean;
var
  i, t : int;
begin
  result := false;
  for i := 1 to mf.k do
  begin
    t := countPr(n, mf.p[i]) - countPr(k, mf.p[i]) - countPr(n - k, mf.p[i]);
    if (t < mf.c[i]) then exit;
  end;
  result := true;
end;

procedure solve;
var
  i, j : int;
begin
  read(n, m);
  i := m;
  j := 2;
  fillchar(mf, sizeof(mf), 0);
  while (i >= j * j) do
  begin
    if (i mod j = 0) then
    begin
      inc(mf.k);
      mf.p[mf.k] := j;
      while (i mod j = 0) do
      begin
        inc(mf.c[mf.k]);
        i := i div j;
      end;
    end;
    inc(j);
  end;
  if (i > 1) then
  begin
    inc(mf.k);
    mf.p[mf.k] := i;
    mf.c[mf.k] := 1;
  end;

  ans[0] := 0;
  for i := 1 to n do
    if (isGood(n - 1, i - 1)) then
    begin
      inc(ans[0]);
      ans[ans[0]] := i;
    end;

  writeln(ans[0]);
  for i := 1 to ans[0] do
  begin
    if (i > 1) then write(' ');
    write(ans[i]);
  end;
end;

begin
  assign(input, cin_file);
  reset(input);
  assign(output,  cout_file);
  rewrite(output);

  solve;

  close(input);
  close(output);
end.