#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int x, d, nxt = 1, arr[10001] = {0}, pos = 0;
  cin >> x >> d;
  for (int j = 30; j >= 0; j--)
    if (x >= (((long long int)1 << j))) {
      x -= ((long long int)1 << j);
      for (int i = 1; i <= j; i++) arr[pos++] = nxt;
      nxt += d;
      arr[pos++] = nxt;
      nxt += d;
    }
  if (x == 0) {
    cout << pos << endl;
    for (int j = 0; j < pos; j++) cout << arr[j] << " ";
    cout << endl;
  } else
    cout << -1 << endl;
  return 0;
}
