#include <bits/stdc++.h>
using namespace std;
int sumNums(vector<int> powers) {
  int total = 0;
  for (int i = 0; i < (int)powers.size(); i++) total += powers[i];
  return total;
}
int main() {
  int X, d;
  cin >> X >> d;
  int maxPower = 30;
  vector<int> powers;
  while (X) {
    while ((1 << maxPower) - 1 > X) {
      maxPower--;
    }
    X -= ((1 << maxPower) - 1);
    powers.push_back(maxPower);
  }
  long long int cur = 1LL;
  cout << sumNums(powers) << endl;
  for (int i = 0; i < (int)powers.size(); i++) {
    for (int j = 0; j < (int)powers[i]; j++) {
      cout << cur << " ";
    }
    cur += (long long int)d;
  }
  cout << endl;
  return 0;
}
