

{$APPTYPE CONSOLE}
var
  a,d:array[1..100000] of integer;
  n,m:longint;

procedure mult(X:longint);
var i:longint;
begin
  i:=2;
  while (x>1) do
	begin
	  while(x mod i=0) do
		begin
		  inc(a[i]);
		  x:=x div i;
		end;
	  inc(i);
	end;
end;

function GetM:boolean;
var
  i:longint;
  x:longint;
begin
  for i:=1 to n do
	d[i]:=0;
  i:=2;
  x:=m;
  while (x>1)and(i<=n) do
	begin
	  while(x mod i=0) do
		begin
		  inc(d[i]);
		  x:=x div i;
		end;
	  inc(i);
	end;
  if (i<=n) then getm:=true else getm:=false;
end;


procedure divide(X:longint);
var i:longint;
begin
  i:=2;
  while (x>1) do
	begin
	  while(x mod i=0) do
		begin
		  dec(a[i]);
		  x:=x div i;
		end;
	  inc(i);
	end;
end;


function isdiv:boolean;
var
  fl1:boolean;
  cyc1:integer;
begin
  fl1:=true;
  for cyc1:=1 to n do
	fl1:=fl1 and (a[cyc1]>=d[cyc1]);
  isdiv:=fl1;
end;


var
   cyc1,j,sc:longint;
   fl1:boolean;
   ans:array[1..100000] of longint;
begin
  Assign(Input, 'irrelevant.in');
  Reset(Input);
  Assign(Output, 'irrelevant.out');
  Rewrite(Output);
  readln(n,m);

  if getm then
	begin
	  sc:=0;
	  for cyc1:=1 to n do
		a[cyc1]:=0;
	  mult(1);

	  for cyc1:=1 to (n div 2) do
		begin
		  mult(n-cyc1);
		  divide(cyc1);
		  if isdiv then
			begin
			  if cyc1=n div 2 then fl1:=true;
			  inc(sc);
			  ans[sc]:=cyc1+1;
			end;
		end;
	  if fl1 then
		begin
		  for cyc1:=1 to sc-1 do
			ans[2*sc-cyc1]:=n+1-ans[cyc1];
		  sc:=2*sc-1;
		end
	  else
		begin
		  for cyc1:=1 to sc do
			ans[2*sc+1-cyc1]:=n+1-ans[cyc1];
		  sc:=2*sc;


		end;

	  writeln(sc);
	  for cyc1:=1 to sc do
		write(ans[cyc1],' ');
	end
   else writeln(0);

  Close(input);
  Close(Output);
end.
