#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(NULL);
  long long powof2[64];
  powof2[0] = 1;
  for (long long i = 1; i < 64; i++) {
    powof2[i] = powof2[i - 1] * 2;
  }
  long long x, d;
  cin >> x >> d;
  long long arr[10000];
  long long kitta = 0;
  long long start = 63;
  long long current = 0, current2 = 1;
  for (start = 63; x > 0 && start > 0; start--) {
    long long inter = 0;
    while (x >= (powof2[start] - 1)) {
      inter++;
      kitta += start;
      x -= (powof2[start] - 1);
    }
    while (inter--) {
      for (long long i = 0; i < start; i++) {
        if (current >= 10000) {
          cout << -1;
          return 0;
        }
        arr[current] = current2;
        if (current2 > 1e18) {
          cout << -1;
          return 0;
        }
        current++;
      }
      current2 += d;
    }
  }
  cout << kitta << '\n';
  for (long long i = 0; i < kitta; i++) cout << arr[i] << ' ';
}
