#include <bits/stdc++.h>
using namespace std;
long long d;
long long fun(long long X) {
  long long D = 0;
  for (; D <= d; D++) {
    if (pow(2, D + 1) > X) break;
  }
  return D;
}
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long X;
  cin >> X >> d;
  long long y = pow(2, d) - 1;
  if (X == y) {
    cout << d << endl;
    for (long long i = 1; i <= d; i++) cout << i << " ";
    return 0;
  }
  long long N = 0, L = 1;
  if (d == 1) {
    vector<long long> ans;
    while (X) {
      long long p = 1;
      while (true) {
        if (pow(2, p + 1) > X) break;
        p++;
      }
      N += p;
      X -= pow(2, p) - 1;
      for (long long i = 0; i < p; i++) ans.push_back(L);
      L += 2;
      if (X == 1) {
        X = 0;
        ans.push_back(L + 10);
        N++;
      }
    }
    cout << N << endl;
    for (long long i : ans) cout << i << " ";
    return 0;
  }
  long long n = 0;
  vector<long long> ans;
  long long l = 1;
  while (X) {
    y = fun(X);
    n += y;
    X -= pow(2, y) - 1;
    for (long long i = 1; i <= y; i++) {
      if (d == 1)
        ans.push_back(l);
      else
        ans.push_back(i + l);
    }
    l += y + d + 2;
    if (X == 1) {
      ans.push_back(l + 2 * d);
      n++;
      X = 0;
    }
    if (n > 10000) {
      cout << "-1";
      return 0;
    }
  }
  cout << n << endl;
  for (auto i : ans) cout << i << " ";
  return 0;
}
