#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int64_t X, d;
  cin >> X >> d;
  int64_t start = 1;
  vector<int64_t> result;
  while (X != 0) {
    int repeat_count = log2(X);
    for (int i = 0; i < repeat_count; i++) result.push_back(start);
    int64_t largest = int64_t(pow(2, repeat_count));
    X = X - largest;
    start += d;
    result.push_back(start);
    start += d;
  }
  cout << result.size() << endl;
  for (auto i : result) cout << i << " ";
  cout << endl;
  return 0;
}
