#include <bits/stdc++.h>
using namespace std;
const long double EPS = 0.00000001;
const long long INF = 1e18;
const long long mod = 1e9 + 7;
long long x, d, t = 1, cnt;
vector<long long> ans;
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> x >> d;
  for (long long i = 60; i >= 1; --i) {
    if (((x >> i) & 1)) {
      for (long long j = 1; j <= i; ++j) {
        ans.push_back(t);
      }
      ++cnt;
      t += d + 1;
    }
  }
  while (cnt--) {
    ans.push_back(t);
    t += d + 1;
  }
  if (x & 1) ans.push_back(t);
  cout << ans.size() << "\n";
  for (long long i : ans) cout << i << " ";
  return 0;
}
