#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, m, i, j, k, d, x, p, q, f = 0;
  cin >> x >> d;
  long long a[10005], h = 0, g = 1;
  while (x > 0) {
    if (x == 1) {
      a[h++] = g;
      break;
    } else if ((x & x + 1) == 0) {
      k = ceil((log(x) / log(2)));
    } else {
      k = floor((log(x) / log(2)));
    }
    i = k;
    k = pow(2, k);
    x = x - k + 1;
    for (q = 1; q <= i; q++) a[h++] = g;
    g += d + 1;
  }
  cout << h << "\n";
  for (i = 0; i < h; i++) cout << a[i] << " ";
  return 0;
}
