#include <bits/stdc++.h>
using namespace std;
const int MAX_LOG = 30;
int top;
long long rez[10000];
int main() {
  int x, d, lastup = 1;
  scanf("%d%d", &x, &d);
  for (int i = MAX_LOG - 1; i >= 1; --i) {
    while ((1 << i) - 1 <= x) {
      for (int j = 0; j < i; ++j) rez[top++] = (long long)d * lastup;
      ++lastup;
      x -= (1 << i) - 1;
    }
  }
  printf("%d\n", top);
  for (int i = 0; i < top; ++i) printf("%lld ", rez[i]);
  return 0;
}
