#include <bits/stdc++.h>
using namespace std;
int main() {
  int X, d;
  cin >> X >> d;
  vector<unsigned long long> ans;
  int ind = 0;
  int cnt = 0;
  unsigned long long num = 1LL;
  while (X) {
    int dig = X % 2;
    if (dig) {
      for (int i = 0; i < ind; i++) {
        ans.push_back(num);
      }
      num += d;
      cnt++;
    }
    ++ind;
    X /= 2;
  }
  for (int i = 0; i < cnt; i++) {
    ans.push_back(num);
    num += d;
  }
  cout << ans.size() << endl;
  for (auto it : ans) {
    cout << it << " ";
  }
  cout << endl;
  return 0;
}
