program i1;

{$APPTYPE CONSOLE}

uses
  SysUtils;
var
  n,m,k,i,j,s,maxp,tm,r: integer;
  a,b: array[1..200000] of integer;
  p,d: array[1..70] of integer;
  q: array[1..200000,1..70] of integer;
  t: boolean;
begin
  AssignFile(Input,'irrelevant.in'); Reset(Input);
  ReadLn(n,m);
  CloseFile(Input);
  p[1] := 2; k := 1;
  for i := 3 to round(int(sqrt(n))) do
  begin
    t := true;
    for j := 1 to k do
      if i mod p[j] = 0 then t := false;
    if t then
    begin
      inc(k);
      p[k] := i;
    end;
  end;
  maxp := k;
  tm := m;
  for i := 1 to maxp do d[i] := 0;
  while tm<>1 do
  begin
    for i := 1 to maxp do
      if tm mod p[i] = 0 then
      begin
        d[i] := d[i] + 1;
        tm := tm div p[i];
      end;
  end;
  r := 0;
  for j := 1 to maxp do
    if d[j]<>0 then
    begin
      q[1,j] := 0;
      if 1 mod p[j] = 0 then q[1,j] := 1 div p[j];
      for i := 2 to n do
         if i mod p[j] = 0 then q[i,j] := q[i-1,j]+i div p[j];
    end;
  for k := 2 to n-1 do
  begin
    t := true;
    for i := 1 to maxp do
    if d[i]<>0 then
    begin
      s := q[n-1,j]-q[n-k-1,j]-q[k,j];
      if s >= d[i] then t := false;
    end;
    if t then
    begin
      inc(r);
      b[r] := k;
    end;
  end;
{  a[1] := 1;
  for i := 2 to 200000 do a[i] := 0;
  for i := 1 to n do
  begin
    b[1] := 1;
    for j := 2 to i do
      b[j] := (a[j-1]+a[j]) mod m;
    for j := 1 to i do
      a[j] := b[j];
  end;
  k := 0;
  for i := 1 to n do
    if a[i]=0 then
    begin
      inc(k);
      b[k] := i;
    end;}
  AssignFile(Output,'irrelevant.out'); Rewrite(Output);
  writeln(r);
  if r>0 then write(b[1]);
  for i := 2 to r do write(' ',b[i]);
  CloseFile(Output);


end.
