#include <bits/stdc++.h>
using namespace std;
long long dx[4] = {1, 0, -1, 0};
long long dy[4] = {0, -1, 0, 1};
template <class T>
void inputVector(vector<T>& v, long long n) {
  v.resize(n);
  for (long long i = 0; i < v.size(); i++) cin >> v[i];
}
signed main() {
  long long X, d;
  cin >> X >> d;
  vector<long long> ret;
  for (long long i = 0; i < (35); i++) {
    long long mask = 1LL << i;
    if ((mask & X) == 0) continue;
    ret.push_back(d * 2 * i + 1);
    for (long long j = 0; j < (i); j++) {
      ret.push_back(d * (2 * i + 1) + 1);
    }
  }
  cout << ret.size() << endl;
  cout << ret[0];
  for (long long i = (1); i <= (ret.size() - 1); i++) {
    cout << " " << ret[i];
  }
  cout << endl;
  return 0;
}
