#include <bits/stdc++.h>
using namespace std;
const long long stp = 1e10;
int main() {
  int X, d;
  cin >> X >> d;
  long long val = 1;
  vector<long long> ans;
  for (int i = 0; i < 30; ++i)
    if ((X >> i) & 1) {
      if (!i) {
        ans.push_back(val);
        val += stp;
        continue;
      }
      for (int j = 0; j < i; ++j) ans.push_back(val);
      val += stp;
      ans.push_back(val);
      val += stp;
    }
  cout << ans.size() << endl;
  copy(ans.begin(), ans.end(), ostream_iterator<long long>(cout, " "));
  return 0;
}
