# UVA 1635 Irrelevant Elements (唯一分解定理 + 组合数)

#include <iostream>
#include <vector>
#include <cstring>
#include <cmath>

using namespace std;
const int maxn = 100000;

vector<int> primes;
bool flag[maxn];

void factors(int n) {
int m = floor(sqrt(n) + 0.5);
for(int i = 2; i <= m; ++i) {
if(n % i == 0) {
primes.push_back(i);
while(n % i == 0) n /= i;
}
}
if(n > 1) primes.push_back(n);
}

int main() {
int n, m;
while(cin >> n >> m) {
memset(flag, 0, sizeof(flag));
primes.clear();
factors(m);
n--;
for(int i = 0; i < primes.size(); ++i) {
int p = primes[i], e = 0;
int min_e = 0, x = m;
while(x % p == 0) { x /= p; min_e++; }
for(int j = 1; j < n; ++j) {
x = n - j + 1;
while(x % p == 0) x /= p, e++;
x = j;
while(x % p == 0) x /= p, e--;
if(e < min_e) flag[j] = true;
}
}
vector<int> ans;
for(int i = 1; i < n; ++i)
if(!flag[i]) ans.push_back(i + 1);
cout << ans.size() << endl;
if(ans.size()) cout << ans.front();
for(int i = 1; i < ans.size(); ++i)
cout << ' ' << ans[i];
cout << endl;
}
return 0;
}