#include <bits/stdc++.h>
using namespace std;
priority_queue<long long int> dif;
vector<long long int> vec;
long long int a[1000000], b[1000000];
int main() {
  long long int x, d, contador = 0, i;
  long long int pot, exp;
  cin >> x >> d;
  while (x > 0) {
    x++;
    pot = 1;
    exp = 0;
    while (pot <= x) {
      pot = pot * 2;
      exp++;
    }
    for (i = 0; i < exp - 1; i++) {
      vec.push_back(d * contador + 1);
    }
    contador++;
    x = x - pot / 2;
  }
  cout << vec.size() << "\n";
  for (i = 0; i < vec.size(); i++) cout << vec[i] << " ";
}
