#include <bits/stdc++.h>
using namespace std;
int main() {
  int x, d;
  cin >> x >> d;
  vector<long long> res;
  long long start = 1;
  while (x) {
    int cur = 1;
    int cnt = 0;
    while (cur * 2 - 1 <= x) {
      cur *= 2;
      cnt++;
    }
    x -= cur - 1;
    for (int i = 0; i < cnt; i++) res.push_back(start);
    start += d + 1;
  }
  if (res.size() > 10000) {
    cout << -1 << endl;
    return 0;
  }
  cout << res.size() << endl;
  for (int i = 0; i < res.size(); i++) cout << res[i] << " ";
}
