#include <bits/stdc++.h>
using namespace std;
long long x, d, f[35], a = 1;
vector<long long> v;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> x >> d;
  f[0] = 1;
  for (long long i = 1; i <= 33; i++) f[i] = f[i - 1] * 2;
  for (long long i = 33; i > 0; i--) {
    while (x >= f[i] - 1) {
      x -= f[i] - 1;
      for (long long j = 0; j < i; j++) v.push_back(a);
      a += d + 1;
    }
  }
  cout << v.size() << endl;
  for (auto z : v) cout << z << " ";
  return 0;
}
