#include <bits/stdc++.h>
using namespace std;
const int N = 100009;
const int MOD = 1e9 + 7;
int dX[] = {0, 0, 1, -1};
int dY[] = {1, -1, 0, 0};
long long fastP(long long b, int p) {
  if (p == 0)
    return 1;
  else if (p == 1)
    return b;
  long long a = fastP(b, p / 2);
  if (p & 1)
    return a * a * b;
  else
    return a * a;
}
int main() {
  long long x, d, num = 1;
  cin >> x >> d;
  vector<long long> v;
  while (x) {
    int l = 0, r = 63;
    while (l < r) {
      int mid = l + (r - l + 1) / 2;
      if (fastP(2, mid) - 1 <= x)
        l = mid;
      else
        r = mid - 1;
    }
    for (int i = 0; i < l; ++i) v.push_back(num);
    x -= (fastP(2, l) - 1);
    num += d;
  }
  cout << (v.size()) << endl;
  for (int i = 0; i < (v.size()); ++i) printf("%lld ", v[i]);
  return 0;
}
