#include <bits/stdc++.h>
using namespace std;
int x, d;
void solve() {
  vector<long long> ans;
  long long s = 1;
  while (x) {
    for (int i = 30; i > 0; i--) {
      if ((1 << i) - 1 <= x) {
        for (int j = 0; j < i; j++) ans.push_back(s);
        s += d;
        x -= (1 << i) - 1;
      }
    }
  }
  printf("%d\n", (int)ans.size());
  for (auto it : ans) printf("%I64d ", it);
  puts("");
}
int main() {
  scanf("%d %d", &x, &d);
  solve();
  return 0;
}
