#include <bits/stdc++.h>
using namespace std;
long long ans[10005], cnt = 0;
int main() {
  int x, d;
  cin >> x >> d;
  long long a = 1;
  int n = 0;
  while (x) {
    if (x % 2 == 1) {
      for (int i = 0; i < n; i++) {
        ans[cnt++] = a;
      }
      a += d + 1;
      ans[cnt++] = a;
      a += d + 1;
    }
    x /= 2;
    n++;
  }
  cout << cnt << endl;
  cout << ans[0];
  for (int i = 1; i < cnt; i++) {
    cout << " " << ans[i];
  }
  cout << endl;
  return 0;
}
