#include <bits/stdc++.h>
using namespace std;
long long power(long long a, long long b, long long c) {
  long long x = 1, y = a;
  while (b > 0) {
    if (b & 1) x = (x * y) % c;
    y = (y * y) % c;
    b /= 2;
  }
  return x % c;
}
long long po[35];
int main() {
  long long x, d, to = 4, cur = 1;
  scanf("%lld%lld", &x, &d);
  po[1] = 1;
  for (int i = 2; i <= 32; ++i) {
    po[i] = to - 1;
    to *= 2LL;
  }
  vector<long long> ans;
  while (x > 0) {
    long long num = 0;
    for (int i = 32; i >= 1; --i) {
      if (po[i] <= x) {
        x -= po[i];
        num = i;
        break;
      }
    }
    for (int i = 1; i <= num; ++i) ans.push_back(cur);
    cur += d;
  }
  long long sz = ans.size();
  if (sz > 10000) {
    printf("-1\n");
  } else {
    printf("%lld\n", sz);
    for (auto u : ans) {
      printf("%lld ", u);
    }
    printf("\n");
  }
  return 0;
}
