#include <bits/stdc++.h>
using namespace std;
long long x, d, v;
vector<long long> res;
void solve() {
  cin >> x >> d;
  res.clear();
  v = 1;
  for (int j = 0; j <= 30; j++) {
    if ((1 << j) & x) {
      for (int k = 1; k <= j; k++) res.push_back(v);
      v += d + 1;
      res.push_back(v);
      v += d + 1;
    }
  }
  cout << res.size() << "\n";
  for (int i = 0; i < res.size(); i++) cout << res[i] << " ";
  cout << "\n";
}
int main() {
  std::ios::sync_with_stdio(0);
  cin.tie(0);
  solve();
  return 0;
}
