#include <bits/stdc++.h>
using namespace std;
int main() {
  long long d, X;
  cin >> X >> d;
  long long k = 0, sz = 25;
  long long n = 0;
  vector<long long> ans(1, 0);
  vector<long long> two(sz + 1, 1);
  for (int i = 1; i <= sz; i++) {
    two[i] = two[i - 1] * 2;
  }
  for (long long p = sz; p >= 1; p--) {
    while (X / two[p]) {
      for (long long j = 0; j < p; j++) {
        ans.push_back(d * k + 1);
        n++;
      }
      k++;
      X -= two[p] - 1;
    }
  }
  if (X) {
    ans.push_back(d * k + 1);
    n++;
  }
  cout << n << endl;
  for (int i = 1; i <= n; i++) {
    cout << ans[i] << " ";
  }
  cout << endl;
  return 0;
}
