#include <bits/stdc++.h>
using namespace std;
vector<long long> v;
int main() {
  std::ios::sync_with_stdio(false);
  long long x, d, i, j, x1, prev, ans = 0;
  cin >> x >> d;
  x1 = x;
  j = 0;
  while (x1 > 0) {
    if (x1 % 2) {
      v.push_back(j);
    }
    j++;
    x1 /= 2;
  }
  for (i = 0; i < v.size(); i++) {
    ans += v[i];
  }
  cout << ans + v.size() << endl;
  prev = 1;
  for (i = 0; i < v.size(); i++) {
    for (j = 0; j < v[i]; j++) {
      cout << prev << " ";
    }
    prev += d;
  }
  for (i = 0; i < v.size(); i++) {
    cout << prev << " ";
    prev += d;
  }
}
