#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long x, d;
  cin >> x >> d;
  vector<long long> ans;
  long long cnt = 1;
  while (x > 0) {
    long long z;
    for (long long i = 0; pow(2, i) - 1 <= x; ++i) {
      z = i;
    }
    x -= pow(2, z) - 1;
    for (long long j = 0; j < z; ++j) {
      ans.push_back(cnt);
    }
    cnt += 2 * d;
  }
  cout << ans.size() << "\n";
  for (auto i : ans) cout << i << " ";
}
