#include <bits/stdc++.h>
using namespace std;
long long i = 1;
vector<long long> a;
long long x, d;
void show() {
  int x = a.size();
  for (int i = 0; i < x; i++) cout << a[i] << " ";
}
void fun(long long x) {
  if (x == 0) return;
  long long val = 2;
  long long k = 1;
  while (val <= x) {
    val *= 2;
    k++;
  }
  val /= 2;
  k--;
  if (k > 0) {
    for (int j = 1; j <= k; j++) a.push_back(i);
    x = x - val + 1;
    i += d + 1;
    fun(x);
  } else
    a.push_back(i + d + 2);
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int t = 1;
  while (t--) {
    cin >> x >> d;
    long long val = 2;
    while (val <= x) {
      val *= 2;
      i++;
    }
    val /= 2;
    i--;
    for (int j = 1; j <= i; j++) a.push_back(1);
    x = x - val + 1;
    i = d + 2;
    fun(x);
    cout << a.size() << endl;
    show();
  }
}
