#include <bits/stdc++.h>
using namespace std;
vector<long long> po;
vector<long long> ans;
vector<long long> res;
int main() {
  long long x, d;
  scanf("%lld %lld", &x, &d);
  po.push_back(0);
  long long cnt = 1;
  while (powl(2, cnt) - 1 <= 1000000000) {
    po.push_back(powl(2, cnt) - 1);
    cnt++;
  }
  for (long long i = (long long)po.size() - 1; i >= 1; i--) {
    while (x - po[i] >= 0) {
      x -= po[i];
      ans.push_back(i);
    }
  }
  long long base = 1;
  long long sz = 0;
  for (long long i = 0; i < ans.size(); i++) {
    long long key = ans[i];
    sz += key;
    for (long long j = 0; j < key; j++) {
      res.push_back(base);
    }
    base += (d + 1);
  }
  cout << sz << endl;
  for (long long i = 0; i < res.size(); i++) {
    printf("%lld ", res[i]);
  }
  cout << endl;
  return 0;
}
