#include <bits/stdc++.h>
using namespace std;
const long long int mod = 1000000007;
const long long int inf = 1e17;
const long long int N = 1e5 + 5;
void __solve() {
  long long int n, d;
  cin >> n >> d;
  long long int cur = 1;
  std::vector<long long int> ans;
  while (n > 0) {
    for (long long int i = 40; i >= 0; i--) {
      if (((1LL << i) - 1) <= n and n > 0) {
        n -= (1LL << i) - 1;
        for (long long int j = 0; j < i; j++) ans.push_back(cur);
        cur += d + 1;
      }
    }
  }
  cout << (long long int)((ans).size()) << '\n';
  for (auto to : ans) {
    cout << to << ' ';
  }
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long int T = 1;
  while (T--) {
    __solve();
    cout << '\n';
  }
}
