#include <fstream>
#include <vector>
#include <cstdio>
#include <cmath>
//#include <iostream>
using namespace std;

int n,m;

vector<int> alga;
vector<int> ma;
vector<vector<int> > ia;
vector<vector<int> > fia;
vector<int> tyhi;
	
void tegurda_m(){
	int lopp=int(sqrt(m))+1;
	int a=m;
	for (int i=2; i<=lopp; i++){
		if (i>a) break;
		if ((a%i)==0){
			alga.push_back(i);
			ma.push_back(0);
			while ((a>1) && (a%i==0)){
				ma[ma.size()-1]++;
				a=a/i;
			}
		}
	}
	if (a>1){
		alga.push_back(a);
		ma.push_back(1);
	}

	for (a=0; a<alga.size(); a++){
//	cout << alga[a] << " " << ma[a] << endl;
	}

}



void tee_ia(){
	int i;
	for (i=0; i<alga.size(); i++) tyhi.push_back(0);
	for (i=0; i<=n; i++){
		ia.push_back(tyhi);
		fia.push_back(tyhi);
	}
	for (i=0; i<alga.size(); i++){
		int p0=alga[i];
		__int64 p=p0;
		while (p<=n){
			int j=p;
			while (j<=n){
				ia[j][i]++;
				j+=p;
			}
			p*=p0;
		}
	}

	//fia[0]=tyhi;
	fia[1]=ia[1];
	for (i=2; i<=n; i++){
		for (int j=0; j<fia[0].size(); j++) fia[i][j]=fia[i-1][j]+1;
	}
}

bool irr(int i){
	for (int k=0; k<alga.size(); k++){
//		cout << k << " " << alga[k] << " " << fia[n][k] << " " << fia[i][k] << " " << fia[n-i][k] << " " << ma[k] << endl;
		if (fia[n-1][k]-fia[i][k]-fia[n-1-i][k]<ma[k]) return false;
	}
	return true;
}
	


int main(){
	ifstream sis("irrelevant.in");
	sis >> n >> m;

	tegurda_m();
	tee_ia();

	vector<int> sol;

	FILE *f;
	f=fopen("irrelevant.out","w");
	for (int i=0; i<=n-1; i++){
		if (irr(i)) {
				//fprintf(f,"%d\n",i);
				sol.push_back(i+1);
//				cout << "irr" << i << endl;

		}
	}
	fprintf(f,"%d\n",sol.size());
	for (int j=0; j<sol.size(); j++) fprintf(f,"%d ",sol[j]);


	fclose(f);
	return 0;
}
