#include <bits/stdc++.h>
using namespace std;
int main() {
  long long x, d;
  cin >> x >> d;
  int n = log2(x + 1);
  vector<long long> v;
  long long tmp = 1;
  long long size;
  long long limit;
  long long var = x;
  long long cnt = 0;
  long long nb = __builtin_popcount(x);
  for (; var;) {
    if (var & 1) {
      for (long long j = 0; j < cnt; j++) v.push_back(tmp);
      tmp += d;
    }
    cnt++;
    var >>= 1;
  }
  while (nb--) v.push_back(tmp), tmp += d;
  size = v.size();
  if (tmp > 1e18 || size > 1e4) {
    cout << -1 << endl;
    return 0;
  }
  cout << size << endl;
  for (int i = 0; i < v.size(); i++) cout << v[i] << " ";
  return 0;
}
