#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long x, d;
  while (cin >> x >> d) {
    long long sum = 0;
    long long y = x;
    vector<long long> ans;
    long long val = 1;
    while (1) {
      long long z = log2(y);
      sum += ((1LL << z) - 1);
      y = y - ((1LL << z) - 1);
      for (int i = 1; i <= z; i++) {
        ans.push_back(val);
      }
      val += (d + 1);
      if (y == 1) {
        ans.push_back(val);
        break;
      }
    }
    cout << ans.size() << endl;
    for (int i = 0; i < ans.size(); i++) {
      cout << ans[i];
      if (i == ans.size() - 1)
        cout << endl;
      else
        cout << " ";
    }
  }
  return 0;
}
