program iasdf;

{$APPTYPE CONSOLE}

uses
  SysUtils;

var i,k,n,m:longint;
    a:array [1..100000] of longint;
    tmp:int64;
begin
  assign(input,'irrelevant.in'); reset(input);
  assign(output,'irrelevant.out');rewrite(output);
  readln(n,m);
  tmp:=1;k:=0;
  if tmp Mod m =0 then
  begin
    inc(k) ;
    a[k]:=1;
  end;
  for i:=1 to n-1 do
  begin
    tmp:=tmp*(n-i) div i;
    if tmp Mod m =0 then
    begin
      inc(k) ;
      a[k]:=i+1;
    end;
  end;
  writeln(k)  ;
  for i:=1 to k-1 do write(a[i],' '); if k<>0 then write(a[k]);
  close(input);
  close(output);
end.
