#include <bits/stdc++.h>
using namespace std;
vector<long long int> v;
vector<long long int> ans;
int main() {
  long long int x, d;
  cin >> x >> d;
  while (x > 0) {
    v.push_back(x % 2);
    x /= 2;
  }
  long long int num = 1;
  for (int i = 0; i < v.size(); i++) {
    if (v[i] == 1) {
      for (int j = 0; j < i; j++) ans.push_back(num);
      num += d;
      ans.push_back(num);
      num += d;
    }
  }
  cout << ans.size() << endl;
  for (int i = 0; i < ans.size(); i++) cout << ans[i] << " ";
}
