#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[]) {
  long long x, d, k = 1;
  cin >> x >> d;
  vector<long long> ans;
  while (x) {
    long long rem = 0;
    for (int i = 31; i >= 0; --i) {
      if (x >> i & 1) {
        long long tmp = i;
        if (i == 0) {
          ans.push_back(k);
          rem--;
        }
        while (tmp--) ans.push_back(k);
        k += d;
        rem++;
      }
    }
    x = rem;
  }
  cout << ans.size() << endl;
  for (int i = 0; i < ans.size(); ++i) cout << ans[i] << " ";
  cout << endl;
  return 0;
}
