program zi;

{$APPTYPE CONSOLE}

uses
  SysUtils;

var
  a:array of int64;
  b:array of boolean;
  n,i,j:integer;
  m:int64;
begin
  assign(input,'irrelevant.in');
  reset(input);
  assign(output,'irrelevant.out');
  rewrite(output);
  readln(n,m);
  setlength(a,n);
  setlength(b,n);
  a[0]:=1;
  j:=0;
  for i:= 0 to n-1 do b[i]:=false;
  for i:= 1 to n-1 do begin
    a[i]:=(a[i-1]*(n-i))div(i);
    if a[i] mod m = 0 then begin b[i]:=true; inc(j);end;
  end;
  writeln(j);
  for i:= 0 to n-1 do
    if b[i] then begin dec(j);if j> 0 then write(i+1,' ')
                              else write(i+1);
  end;
end.
 