program Project2;

uses
  SysUtils;

var
	mas, mas1, ans: array [0..100001] of integer;
  n, m, i, j, nans: integer;

begin
	assignfile(input, 'irrelevant.in');
  assignfile(output, 'irrelevant.out');
  reset(input);
  rewrite(output);
  //
  readln(n, m);
	fillchar(mas, sizeof(mas), 0);
	fillchar(mas1, sizeof(mas1), 0);
	mas1[1] := 1;
  for i := 1 to n - 1 do
  begin
  	for j := 1 to i + 1 do
	  	mas[j] := mas1[j - 1] + mas1[j];
    mas1 := mas;
  end;
  nans := 0;
  for i := 1 to n do
  begin
  	if mas[i] mod m = 0 then
    begin
    	inc(nans);
      ans[nans] := i;
    end;
  end;
  writeln(nans);
  for i := 1 to nans do
  	write(ans[i], ' ');
end.
