#include <bits/stdc++.h>
using namespace std;
vector<unsigned long long> t;
const unsigned long long inf = 1e18;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  bool ok = false;
  unsigned long long x, d, akt = 0, j = 1, w = 1;
  cin >> x >> d;
  while (x > 0 && w <= inf) {
    for (unsigned long long i = 1; i <= 32; i++) {
      if ((j << i) - 1 <= x) {
        akt = i;
      }
    }
    x -= (j << akt) - 1;
    for (unsigned long long i = 1; i <= akt; i++) t.push_back(w);
    w += d;
  }
  if (ok) {
    cout << -1 << "\n";
    return 0;
  }
  cout << t.size() << "\n";
  for (unsigned int i = 0; i < t.size(); i++) cout << t[i] << " ";
  return 0;
}
