#include <bits/stdc++.h>
using namespace std;
int x, d, n = 0;
const int N = 10001;
long long ans[N];
int main() {
  ios_base::sync_with_stdio(false);
  cin >> x >> d;
  long long y = 1;
  while (x != 0) {
    int cnt = 1;
    while ((1LL << cnt) - 1 <= x) {
      ans[++n] = y;
      cnt++;
    }
    cnt--;
    x -= ((1 << cnt) - 1);
    y += d;
  }
  cout << n << endl;
  for (int i = 1; i <= n; ++i) {
    cout << ans[i] << " ";
  }
  return 0;
}
