#include <fstream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <math.h>

using namespace std;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int,int> PII;

#define REP(i,n) for (int i = 0; i < (n); i++)
#define IREP(i,n) for (i = 0; i < (n); i++)

int fn(int x, int p) {
   if (x == 0) {
      return 0;
   }
   int res = 0;
   while (x) {
      x /= p;
      res += x;
   }
   return res;
}

int main()
{
   ifstream ifs("irrelevant.in");
   ofstream ofs("irrelevant.out");

   int n,m;
   ifs >> n >> m;

   vector<PII> ps;
   int tm = m;
   for (int i = 2; i < 100000; ++i) {
      if (tm % i == 0) {
         if (ps.size() == 0 || ps.back().first != i) {
            ps.push_back(PII(i, 1));
         } else {
            ++ps.back().second;
         }
         tm /= i;
         --i;
      }
   }
   if (tm != 1) {
      ps.push_back(PII(tm, 1));
   }

   VI res;
   for (i = 0; i <= n-1; ++i) {
      bool ok = true;
      for (int j = 0; j < ps.size(); ++j) {
         int pw = fn(n-1, ps[j].first)-fn(i, ps[j].first)-fn(n-i-1, ps[j].first);
         if (ps[j].second > pw) {
            ok = false;
            break;
         }
      }
      if (ok) res.push_back(i);
   }

   ofs << res.size() << endl;
   for (i = 0; i < res.size(); ++i) {
      if (i != 0) ofs << ' ';
      ofs << res[i]+1;
   }
   ofs << endl;

   return 0;
}