#include <bits/stdc++.h>
using namespace std;
int main() {
  long long x, d, now;
  vector<long long> p;
  scanf("%lld%lld", &x, &d);
  now = 1;
  for (int i = 30; i >= 0; i--) {
    while (x >= (1 << i) - 1) {
      for (int j = 0; j < i; j++) p.push_back(now);
      now += d + 1;
      x -= (1 << i) - 1;
      if (x == 0) break;
    }
    if (x == 0) break;
  }
  printf("%d\n", p.size());
  for (auto i : p) printf("%lld ", i);
}
