#include <bits/stdc++.h>
using namespace std;
int main() {
  int first, d;
  scanf("%d %d", &first, &d);
  long long ans[100000];
  ans[0] = -d + 1;
  int index = 0;
  while (first) {
    for (int i = 1;; i++) {
      if ((1 << i) - 1 > first) {
        i--;
        first -= ((1 << i) - 1);
        ans[index + 1] = ans[index] + d;
        for (int j = index + 2; j <= index + i; j++) {
          ans[j] = ans[j - 1];
        }
        index = index + i;
        break;
      }
    }
  }
  printf("%d\n", index);
  for (int i = 1; i <= index; i++) printf("%lld ", ans[i]);
}
