#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long x, d, cnt = 1;
  cin >> x >> d;
  vector<long long> v;
  long long n = x, size = 0;
  while (n > 0) {
    n++;
    long long temp = log2(n);
    for (int i = 0; i < temp; i++) v.push_back(cnt), size++;
    n -= pow(2, temp);
    cnt += d + 1;
  }
  cout << size << endl;
  for (int i = 0; i < size; i++) cout << v[i] << " ";
  return 0;
}
long long choose(long long n, long long k) {
  if (k == 0) return 1;
  return (n * choose(n - 1, k - 1)) / k;
}
bool isprime(long long n) {
  for (long long i = 2; i * i <= n; i++) {
    if (n % i == 0) return false;
  }
  return true;
}
