#include <bits/stdc++.h>
using namespace std;
long long Pow[10005];
long long ans[10005];
int main() {
  long long N, X, now = 1, i, con = 0, t;
  Pow[0] = 1;
  for (i = 1; i <= 40; i++) Pow[i] = Pow[i - 1] * 2;
  scanf("%lld %lld", &X, &N);
  for (i = 40; i >= 0; i--) {
    while (X && X - (Pow[i] - 1) >= 0) {
      t = i;
      while (t--) ans[con++] = now;
      X -= (Pow[i] - 1);
      now += N;
      now++;
    }
  }
  printf("%lld\n", con);
  for (i = 0; i < con; i++) printf("%lld ", ans[i]);
  return 0;
}
