#include <bits/stdc++.h>
using namespace std;
const long long inf = 2e9;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long x, d;
  cin >> x >> d;
  int cnt = 0;
  long long now = 1;
  vector<long long> ans;
  while (x > 0) {
    if (x & 1) {
      for (int i = 0; i < cnt; i++) ans.push_back(now);
      now += (d + 1);
      ans.push_back(now);
      now += (d + 1);
    }
    cnt++;
    x >>= 1;
  }
  cout << ans.size() << "\n";
  for (auto i : ans) cout << i << " ";
  return 0;
}
