#include <bits/stdc++.h>
using namespace std;
int setBit(int n, int pos) { return n = n | (1 << pos); }
int resetBit(int n, int pos) { return n = n & ~(1 << pos); }
bool checkBit(long long n, long long pos) { return (bool)(n & (1LL << pos)); }
const int MAX = 100010;
const int INF = 2000000000;
vector<long long> V;
int main() {
  long long now = 1LL << 30;
  long long cur = 1;
  long long x, d;
  scanf("%lld %lld", &x, &d);
  for (; now >= 1; now /= 2) {
    if (now <= x) {
      int lala = __builtin_popcount(now - 1);
      for (int i = 1; i <= lala; i++) V.push_back(cur);
      cur += d;
      V.push_back(cur);
      cur += d;
      x -= now;
    }
  }
  if (V.size() > 10000) {
    puts("-1");
    return 0;
  }
  cout << V.size() << endl;
  for (int i = 0; i < V.size(); i++) {
    cout << V[i] << " ";
  }
  puts("");
  return 0;
}
