#include <bits/stdc++.h>
using namespace std;
int main() {
  int x, d;
  cin >> x >> d;
  long long start = 1;
  vector<long long> arr;
  while (x > 0) {
    int toPrint = 1;
    while ((1LL << toPrint) - 1 <= x) toPrint++;
    toPrint--;
    for (long long i = start; i < start + toPrint; i++) arr.push_back(start);
    start += toPrint + d + 1;
    x -= ((1LL << toPrint) - 1);
  }
  if (arr.size() > 1e4 || start >= 1e18) {
    cout << "-1";
    return 0;
  }
  cout << arr.size() << endl;
  for (int i = 0; i < arr.size(); i++) cout << arr[i] << " ";
}
