#include <bits/stdc++.h>
using namespace std;
long long n, d, ans, push;
long long getSequence(long long p) {
  return p == 1LL ? 1LL : ((1LL << p) - 1LL);
}
vector<long long> res;
int main() {
  while (cin >> n >> d) {
    push = 1;
    while (n) {
      long long ans;
      for (long long i = 1; i <= 32; i++) {
        long long x = getSequence(i);
        if (x <= n)
          ans = x;
        else {
          for (int j = 1; j < i; j++) res.push_back(push);
          n -= ans;
          break;
        }
      }
      push += d;
    }
    cout << res.size() << endl;
    for (int i = 0; i < res.size(); i++) cout << res[i] << " ";
    cout << endl;
  }
  return 0;
}
