#include <fstream.h>
#define max 10000
long parz[max], pi; 
long nf[max];
long mp[max];
long ip[max];
long nip[max];

long mas[max],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;

	n--;

	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)
	{
		if (j==pi) {out<<0; return 0;}

		while (k%parz[j]==0) 
		{mp[j]++;k/=parz[j];} 
		j++;  
	}

	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+1; j=0;
		while (k!=1){ while (k%parz[j]==0) {nip[j]--;k/=parz[j];} j++; }

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

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

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

	return 0;
}