#include <bits/stdc++.h>
using namespace std;
namespace {
void Solve(int64_t) {
  int64_t x, d;
  if (not(cin >> x >> d)) return;
  vector<int64_t> res;
  int64_t nx = 1;
  for (int64_t bit = 0, __bit = 31; bit < __bit; ++bit) {
    if (x >> bit & 1) {
      for (int64_t i = 0, __i = bit; i < __i; ++i) res.push_back(nx);
      nx += 1e9;
      res.push_back(nx);
      nx += 1e9;
    }
  }
  cout << ((int64_t)(res.size())) << endl;
  for (auto &r : res) cout << r << " ";
  cout << endl;
}
void Init() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
}
}  // namespace
int32_t main() {
  Init();
  int64_t tests = 11;
  for (int64_t test = 1, __test = tests + 1; test < __test; ++test) Solve(test);
  return 0;
}
