#include <bits/stdc++.h>
using namespace std;
int recur_depth = 0;
template <typename Ostream, typename Cont>
typename enable_if<is_same<Ostream, ostream>::value, Ostream&>::type operator<<(
    Ostream& os, const Cont& v) {
  os << "[";
  for (auto& x : v) {
    os << x << ", ";
  }
  return os << "]";
}
template <typename Ostream, typename... Ts>
Ostream& operator<<(Ostream& os, const pair<Ts...>& p) {
  return os << "{" << p.first << ", " << p.second << "}";
}
void solve() {
  long long int x, d;
  cin >> x >> d;
  long long int cur = 1;
  long long int cnt = 1;
  vector<long long int> ans;
  while (x > 0) {
    ;
    while ((1LL << cnt) - 1 <= x) {
      ans.push_back(cur);
      cnt++;
    }
    cur += d;
    x -= (1 << cnt - 1) - 1;
    cnt = 1;
  }
  cout << ans.size() << endl;
  for (auto e : ans) {
    cout << e << " ";
  }
  cout << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  ;
  solve();
}
