#include <bits/stdc++.h>
using namespace std;
int UpPow(int X) {
  int r = 1, pw = 0;
  while (r < X) {
    r *= 2;
    ++pw;
  }
  if (r > X) {
    r /= 2;
    --pw;
  }
  return pw;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int X, d;
  cin >> X >> d;
  vector<int64_t> result;
  int64_t current = 1;
  while (X > 0) {
    if (X == 1) {
      result.push_back(current);
      break;
    }
    int pw = UpPow(X);
    for (int i = 0; i < pw; ++i) {
      result.push_back(current);
    }
    current += d;
    X -= ((1 << pw) - 1);
  }
  cout << result.size() << '\n';
  for (auto r : result) {
    cout << r << ' ';
  }
  cout << '\n';
  return 0;
}
