#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.precision(0);
  int x, d;
  cin >> x >> d;
  vector<int> blocks;
  for (int i = 0; i < 32; ++i) {
    if (x & (1 << i)) {
      blocks.push_back(i);
    }
  }
  vector<long long> ans;
  long long cur = 5319;
  int szb = (blocks).size();
  for (int i = 0; i < szb; ++i) blocks.push_back(1);
  for (int& el : blocks) {
    for (int i = 0; i < el; ++i) {
      ans.push_back(cur);
    }
    cur += (d + 1);
  }
  cout << (ans).size() << '\n';
  for (long long& el : ans) cout << el << " ";
  return 0;
}
