#include <bits/stdc++.h>
using namespace std;
long long x, d, last = 1;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> x >> d;
  vector<long long> ans;
  while (1) {
    if (!x) break;
    long long sz = 1;
    while ((1LL << sz) - 1 <= x) sz++;
    sz--;
    x -= (1LL << sz) - 1;
    while (sz--) ans.push_back(last);
    last += d;
  }
  assert(ans.size() <= 1e4);
  cout << ans.size() << endl;
  for (long long a : ans) cout << a << " ";
  return 0;
}
