#include <bits/stdc++.h>
using namespace std;
long long x, d, now = 1;
vector<long long> vec;
int main() {
  ios::sync_with_stdio(false), cin.tie(0);
  cin >> x >> d;
  for (int i = 30; ~i && x; i--)
    while ((1 << i) - 1 <= x) {
      for (int j = 0; j < i; j++) vec.push_back(now);
      x -= (1 << i) - 1;
      now += d;
    }
  cout << vec.size() << '\n';
  for (long long num : vec) cout << num << ' ';
  return 0;
}
