#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int X, d, ans = 0, i, j, n, m;
  int c = 0;
  cin >> X >> d;
  int a[10000];
  for (i = 0; i < 10000; i++) {
    a[i] = log2(X);
    ans += a[i];
    X = X - pow(2, a[i]) + 1;
    if (X < 2) break;
  }
  ans += X;
  n = i;
  cout << ans << endl;
  for (i = 0; i <= n; i++) {
    for (j = 0; j < a[i]; j++) cout << 1 + (d + 1) * i << " ";
  }
  m = 1 + (d + 1) * i;
  for (i = 1; i <= X; i++) cout << m + (d + 1) * i << " ";
  return 0;
}
