#include <bits/stdc++.h>
using namespace std;
vector<long long> ans;
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long X, d;
  cin >> X >> d;
  long long cur = 1;
  for (long long i = 0; i < 60; i++) {
    if ((X >> i) & 1) {
      for (long long j = 1; j <= i; j++) ans.push_back(cur);
      ans.push_back(cur + d);
      cur += 2 * d;
    }
  }
  cout << ans.size() << '\n';
  for (long long v : ans) cout << v << ' ';
}
