#include <algorithm>
#include <ctype.h>
#include <math.h>
#include <stdio.h>
#include <string.h>

using namespace std;

FILE* in=fopen("irrelevant.in","r");
//FILE* in=stdin;
FILE* out=fopen("irrelevant.out","w");
//FILE* out=stdout;

const long NPRIME = 40000;
const long S = 1000;//??????

long prime[NPRIME],nprime;
long a[S],b[S];

bool isprime(long n)
{
	if (n==0 || n==1)
		return false;
	for(long i=0;i<nprime && prime[i]*prime[i]<=n;++i)
		if (n%prime[i]==0)
			return false;
	return true;
}

long ins(long m, long p)
{
	long sum=0;
	while(!(m%p))
	{		
		++sum;
		m/=p;
	}
	return sum;
}

long look(long m)
{
	long i,k=0,sum,cur=m;
	for(i=0;i<nprime && prime[i]*prime[i]<=m;++i)
	{
		sum=0;
		while(cur && cur%prime[i]==0)
		{
			++sum;
			cur/=prime[i];
		}
		if (sum)
		{
			a[k]=prime[i];
			b[k++]=sum;
		}
	}
	if (cur>1)
	{
		a[k]=cur;
		b[k++]=1;
	}
	return k;
}

const long N=100010;

long fl[N];

int main()
{
	long i;
	prime[0]=2;
	nprime=1;
	for(i=3;i<=40000;i+=2)
		if (isprime(i))
			prime[nprime++]=i;
	
	long n,m;
	fscanf(in,"%ld%ld",&n,&m);
	n--;

	memset(fl,0,sizeof(fl));
	fl[0]=1;
	long k,c,l,t,p;
	t=look(m);
	for (i=0; i<t; i++) {
		c=0;
		p=a[i];
		for (k=1; k<=n; k++) {
			c+=ins(n-k+1,p)-ins(k,p);
			if (c<b[i])
				fl[k]=1;
		}
	}
	l=0;
	for (i=0; i<=n; i++)
		if (!fl[i])
			l++;
	fprintf(out,"%ld\n",l);
	for (i=0; i<=n; i++)
		if (!fl[i]) {
			l--;
			fprintf(out,"%ld%c",i+1,l?' ':'\n');
		}
	
	return 0;
}