#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, x;
  cin >> n >> x;
  long long cur = 1;
  vector<long long> res;
  for (int i = 30; i >= 1; --i) {
    while ((1 << i) - 1 <= n) {
      n -= (1 << i) - 1;
      for (int j = 0; j < i; ++j) res.push_back(cur);
      cur += x;
    }
  }
  cout << res.size() << '\n';
  for (auto i : res) cout << i << ' ';
}
