#include <bits/stdc++.h>
using namespace std;
const long long int delta = 1e9 + 5;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ;
  int x;
  int d;
  cin >> x >> d;
  vector<long long int> ans;
  long long int cur = 1;
  for (int i = 31; i >= 0; i--) {
    long long int cnt = (1LL << i);
    while (x >= cnt) {
      x -= cnt;
      for (int j = 0; j < i; j++) {
        ans.push_back(cur);
      }
      cur += d;
      ans.push_back(cur);
      cur += d;
    }
  }
  cout << ans.size() << '\n';
  for (auto a : ans) cout << a << " ";
  cout << endl;
  ;
}
