#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int x, d, sz;
  cin >> x >> d;
  int maxi = 10000;
  vector<long long int> ans;
  int i = 1;
  vector<long long int> it;
  long long int x1 = x;
  while (1) {
    if ((x1 - (pow(2, i) - 1)) <= maxi - i && ((x1 - (pow(2, i) - 1)) >= 0)) {
      it.push_back(i);
      sz = (x1 - (pow(2, i) - 1));
      break;
    } else if ((x1 - (pow(2, i) - 1) < 0)) {
      it.push_back(i - 1);
      x1 = ((x1 - (pow(2, i - 1) - 1)));
      maxi = maxi - (i - 1);
      i = 1;
    } else {
      i++;
    }
  }
  long long int y1 = 0;
  for (long long int i = 0; i < it.size(); i++) {
    y1 = y1 + (pow(2, it[i]) - 1);
    for (long long int j = 1; j <= it[i]; j++) {
      ans.push_back(1 + i * d);
    }
  }
  int y = it.size();
  for (long long int j = 1; j <= (sz); j++) {
    ans.push_back(1 + (j + y) * d);
  }
  cout << ans.size() << endl;
  for (int i = 0; i < ans.size(); i++) cout << ans[i] << " ";
  return 0;
}
