#include <bits/stdc++.h>
using namespace std;
vector<long long> vc;
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int x, d, cnt = 0;
  long long cur = 1;
  cin >> x >> d;
  for (int i = 30; i >= 0 && x > 0; i--) {
    if ((1 << i) & x) {
      for (int j = 0; j < i; j++) vc.push_back(cur);
      cnt++;
      cur += (d + 1);
      x -= (1 << i);
    }
  }
  while (cnt--) {
    vc.push_back(cur);
    cur += (d + 1);
  }
  cout << vc.size() << endl;
  for (int i = 0; i < vc.size() - 1; i++) cout << vc[i] << " ";
  cout << vc[vc.size() - 1] << endl;
  return 0;
}
