#include <bits/stdc++.h>
using namespace std;
vector<long long> st;
int main() {
  long long x, d;
  cin >> x >> d;
  if (x == 1) {
    cout << 1 << "\n" << 1;
    return 0;
  }
  long long r = 0;
  for (int i = 40; i >= 0; i--) {
    while (r <= 1e5 && x >= (1LL << i) - 1 && x) {
      st.push_back(i);
      x -= (1LL << i) - 1;
      r += i;
    }
  }
  if (x != 0 || r > 1e4) {
    cout << -1;
    return 0;
  }
  long long l = 1;
  cout << r << endl;
  for (int i = 0; i < st.size(); i++) {
    for (int j = 0; j < st[i]; j++) printf("%I64d ", l);
    l += d;
  }
  return 0;
}
