#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:256000000")
using namespace std;
const int INF = (int)(1e9 + 1e6);
const long long LINF = (long long)(4e18);
const double EPS = 1e-9;
mt19937 ggen;
const long long MOD = (long long)(1e9 + 7);
int t;
void solve();
int main() {
  iostream::sync_with_stdio(false);
  cin.tie(0);
  ggen = mt19937(1337);
  t = 1;
  for (int i = 0; i < t; ++i) {
    solve();
  }
  return 0;
}
long long st[40];
void solve() {
  st[0] = 1;
  for (int i = 1; i < 40; ++i) {
    st[i] = st[i - 1] * 2;
  }
  for (int i = 0; i < 40; ++i) {
    st[i]--;
  }
  long long X, d;
  cin >> X >> d;
  long long X1 = X;
  vector<int> ras;
  for (int i = 39; i >= 0; --i) {
    if (X1 - st[i] >= 0) {
      X1 -= st[i];
      ras.push_back(i);
    }
  }
  vector<long long> ans;
  long long count = 1;
  for (int i = 0; i < (int)(ras).size(); ++i) {
    for (int j = 0; j < ras[i]; ++j) {
      ans.push_back(count);
    }
    count += (d + 228);
  }
  int nn = (int)(ans).size();
  if (X1 + nn > 10000) {
    cout << -1;
    return;
  } else {
    while (X1) {
      ans.push_back(count);
      count += (d + 228);
      X1--;
    }
  }
  cout << (int)(ans).size() << endl;
  for (int i = 0; i < (int)(ans).size(); ++i) {
    cout << ans[i] << " ";
  }
}
