#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, d;
  long long int arr[55] = {0};
  arr[1] = 1;
  for (int i = 2; i <= 35; i++) {
    arr[i] = arr[i - 1] * 2 + 1;
  }
  cin >> n >> d;
  long long int last = 1;
  vector<long long int> vec;
  for (int i = 35; i > 0; i--) {
    long long int temp = n / arr[i];
    if (temp > 0) {
      n -= arr[i] * temp;
      for (int j = 1; j <= temp; j++) {
        for (int k = 1; k <= i; k++) {
          vec.push_back(last);
        }
        last += d;
      }
    }
  }
  if (vec.size() <= 10000) {
    cout << vec.size() << "\n";
    for (int i = 0; i < vec.size(); i++) {
      cout << vec[i] << " ";
    }
  } else {
    cout << "-1";
  }
  return 0;
}
