#include <fstream.h>

long parz[10000], pi; 
long nf[10000];
long mp[10000];
long ip[10000];
long nip[10000];

long mas[10000],mi;

bool parza(long a)
{
	for (int i=2;i*i<=a;i++)
		if (a%i==0) return false;
	return true;
}

int main()
{
	ifstream in("irrelevant.in");
	ofstream out("irrelevant.out");
	
	pi=0; long i; bool x;

	long n, m,k,j;
	in>>n>>m;

	for (i=2;i<=n;i++)
		if (parza(i))
		{parz[pi]=i; pi++; }


	
	for (i=2;i<n;i++)
	{
		k=i; j=0;
		while (k!=1){ while (k%parz[j]==0) {nf[j]++;k/=parz[j];} j++; }
	}

	k=m; j=0;
	while (k!=1){ while (k%parz[j]==0) {mp[j]++;k/=parz[j];} j++;  if (j>pi) {out<<0; return 0;}}

	for (i=0;i<pi;i++)
		nip[i]=nf[i];

	mi=0;

	for (i=1;i<n;i++)
	{
		k=i;j=0;
		while (k!=1){ while (k%parz[j]==0) {ip[j]++;k/=parz[j];} j++; }

		k=n-i; j=0;
		while (k!=1){ while (k%parz[j]==0) {nip[j]--;k/=parz[j];} j++; }

		x=true;
		for (i=0;i<pi;i++)
			if (mp[i]+ip[i]+nip[i]>nf[i])
			{x= false; break;}

		if (x)
		{mas[mi]=i; mi++;}
	}

	out<<mi<<endl;
	for (i=0;i<mi-1;i++)
		out<<mas[i]<<" ";
	out<<mas[mi-1]<<" ";

	return 0;
}