#include <bits/stdc++.h>
using namespace std;
int main() {
  long long x, d;
  while (~scanf("%lld%lld", &x, &d)) {
    vector<pair<long long, int> > counts;
    long long sum = 0;
    long long num = 1;
    while (x > 0) {
      long long two = 1;
      int count = 0;
      while (two - 1 <= x) two *= 2, count++;
      two /= 2, count--;
      sum += count;
      counts.push_back(pair<long long, int>(num, count));
      x -= two - 1;
      num += d;
    }
    if (counts.back().first < 1e18) {
      printf("%lld\n", sum);
      for (int i = 0; i < counts.size(); i++)
        for (int j = 0; j < counts[i].second; j++)
          printf("%lld ", counts[i].first);
      printf("\n");
    }
  }
  return 0;
}
