#include <bits/stdc++.h>
using namespace std;
template <class T1, class T2>
void print(T1 a[], T2 n) {
  for (T2 i = 0; i < n; i++) {
    cout << a[i] << " ";
  }
  cout << endl;
}
template <class T1, class T2>
void print(vector<T1> a, T2 n) {
  for (T2 i = 0; i < n; i++) {
    cout << a[i] << " ";
  }
  cout << endl;
}
long long int modexpo(long long int a, long long int b, long long int m) {
  if (b == 0) {
    return 1;
  } else if (a == 1) {
    return 1;
  }
  if (b % 2 == 0) {
    long long int t = modexpo(a, b / 2, m);
    t = (t * t) % m;
    return t;
  } else {
    long long int t = modexpo(a, b / 2, m);
    t = (t * t) % m;
    t = (t * a) % m;
    return t;
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int n, k;
  cin >> n >> k;
  long long int t = n;
  int c = 0;
  long long int m = 1;
  vector<long long int> ans;
  while (t > 0) {
    long long int r = t % 2;
    if (r & 1) {
      if (c - 1 >= 0) {
        long long int q = c;
        for (int i = 0; i < q; i++) {
          ans.push_back(m);
        }
        m += k;
      }
      ans.push_back(m);
      m += k;
    }
    c++;
    t /= 2;
  }
  cout << ans.size() << endl;
  print(ans, ans.size());
}
