#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long x, d;
  cin >> x >> d;
  vector<long long> v;
  vector<long long> tec(40, 1);
  for (long long i = 2; i <= 35; i++) tec[i] = 2 * tec[i - 1] + 1;
  long long ind = 1, sum = 0;
  while (x > 0) {
    ind = 32;
    while (x < tec[ind]) ind--;
    x -= tec[ind];
    v.push_back(ind);
    sum += ind;
  }
  cout << sum << endl;
  long long raz = v.size();
  long long temp = 1;
  for (long long i = 0; i < raz; i++) {
    for (long long j = 1; j <= v[i]; j++) cout << temp << " ";
    temp += d;
  }
  return 0;
}
