#include <bits/stdc++.h>
using namespace std;
int findx(long long int x) {
  int count1 = 0;
  x++;
  while (x) {
    x = x / 2;
    count1++;
  }
  return count1 - 1;
}
int main() {
  long long int x, d, giv, rem, count1 = 0, temp;
  vector<long long int> fin;
  cin >> x;
  cin >> d;
  giv = 1;
  while (x > 0) {
    int count1 = findx(x);
    if (count1 == 0) break;
    x = x - (pow(2, count1) - 1);
    for (int i = 0; i < count1; i++) fin.push_back(giv);
    giv = giv + d;
  }
  cout << fin.size() << endl;
  for (int i = 0; i < fin.size(); i++) cout << fin[i] << " ";
  return 0;
}
