#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
long long power(long long base, long long expo, long long md = mod) {
  if (base == 0) return 0;
  long long res = 1;
  base %= md;
  while (expo > 0) {
    if (expo & 1) {
      res = res * base;
      res %= md;
    }
    expo >>= 1;
    base = (base * base) % md;
  }
  return res;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long tt = 1;
  for (long long tc = 1; tc <= tt; tc++) {
    long long x, d;
    cin >> x >> d;
    bitset<69> bit(x);
    vector<long long> v;
    for (long long i = 0; i < 69; i++) {
      if (bit[i]) {
        v.push_back(i);
      }
    }
    vector<long long> sol;
    long long ins = 1, cnt = 0;
    for (auto &xo : v) {
      long long times = xo;
      cnt++;
      while (times--) {
        sol.push_back(ins);
      }
      ins += d;
    }
    for (long long i = 0; i < cnt; i++) {
      sol.push_back(ins);
      ins += d;
    }
    if ((long long)sol.size() > (10000))
      cout << "-1\n";
    else {
      cout << sol.size() << "\n";
      for (auto &xo : sol) cout << xo << " ";
      cout << "\n";
    }
  }
  return 0;
}
