#include <bits/stdc++.h>
using namespace std;
int x, d, i;
vector<long long> v;
long long temp = 1;
long long po(int power) {
  long long ans = 1;
  for (int j = 0; j < power; j++) ans *= 2;
  return ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin >> x >> d;
  while (x > 0) {
    if (x == 1) {
      v.push_back(temp);
      break;
    }
    int ln = floor(log2(x));
    x -= (po(ln) - 1);
    for (i = 0; i < ln; i++) v.push_back(temp);
    temp += d;
  }
  cout << v.size() << "\n";
  cout << v[0];
  for (i = 1; i < v.size(); i++) cout << " " << v[i];
  return 0;
}
