#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int x = 0, c = getchar(), f = 0;
  for (; c > '9' || c < '0'; f = c == '-', c = getchar())
    ;
  for (; c >= '0' && c <= '9'; c = getchar()) x = (x << 1) + (x << 3) + c - '0';
  return f ? -x : x;
}
long long a[50];
int main() {
  long long k, d;
  long long sum = 0;
  int g = 0;
  a[0] = 0;
  for (int i = 1;; i++) {
    sum = sum * 2 + 1;
    a[i] = sum;
    if (sum > 1000000009) {
      g = i;
      break;
    }
  }
  while (~scanf("%I64d%I64d", &k, &d)) {
    queue<int> q;
    long long ans = 0;
    while (k > 0) {
      int id = upper_bound(a + 1, a + g + 1, k) - a - 1;
      k -= a[id];
      q.push(id);
      ans += id;
    }
    printf("%I64d\n", ans);
    bool flag = false;
    long long c = 1 + d;
    while (!q.empty()) {
      int n = q.front();
      q.pop();
      if (!flag) {
        printf("1");
        for (int i = 2; i <= n; i++) printf(" 1");
        flag = true;
      } else {
        for (int i = 1; i <= n; i++) printf(" %I64d", c);
        c += d;
      }
    }
    printf("\n");
  }
  return 0;
}
