#include <bits/stdc++.h>
using namespace std;
const int N = 10005;
int x, d;
int n;
long long a[N];
int main() {
  cin >> x >> d;
  long long t = 1;
  for (int i = 31; i >= 1; i--) {
    while (x >= (1 << i) - 1) {
      for (int j = 0; j < i; j++) a[++n] = t;
      t += d;
      x -= (1 << i) - 1;
    }
  }
  printf("%d\n", n);
  for (int i = 1; i <= n; i++) cout << a[i] << " ";
  return 0;
}
