#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 7;
long long n, m;
vector<long long> v;
int main() {
  long long x, d, cur_sum = 0, n = 0;
  cin >> x >> d;
  vector<long long> ans = {1LL};
  while (x > cur_sum) {
    while (cur_sum - 1LL + (1LL << (long long)ans.back() + 1) <= x) {
      ans[ans.size() - 1]++;
    }
    cur_sum += ((1LL << (long long)ans.back()) - 1LL);
    if (cur_sum < x) {
      ans.push_back(1);
    }
  }
  for (int i = 0; i < ans.size(); i++) {
    n += ans[i];
  }
  if (n > (int)1e4) {
    cout << "-1\n";
    return 0;
  }
  cout << n << "\n";
  for (int i = 0; i < ans.size(); i++) {
    for (int j = 0; j < ans[i]; j++) {
      cout << 1 + (d + 1) * (i) << " ";
    }
  }
  cout << "\n";
  return 0;
}
