#include <bits/stdc++.h>
using namespace std;
template <typename T1, typename T2>
bool umin(T1 &x, const T2 &y) {
  if (x > y) return x = y, true;
  return false;
}
template <typename T1, typename T2>
bool umax(T1 &x, const T2 &y) {
  if (x < y) return x = y, true;
  return false;
}
template <typename T>
T getint() {
  char c = getchar();
  T p = 1, x = 0;
  while (c == ' ' || c == '\n') c = getchar();
  if (c == '-') p = -1, c = getchar();
  while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
  return x * p;
}
const int INF = (int)2e9 + 10;
const int mod = (int)1e9 + 7;
const int N = (int)1e6 + 10;
const long long LLINF = (long long)1e18 + 11;
const long double pi = acos(-1.0);
const long double eps = 1e-10;
int x, d;
int main() {
  ios_base::sync_with_stdio(0);
  cin >> x >> d;
  long long mn = 1;
  vector<long long> ans;
  for (int i = 0; i < 31; ++i) {
    if (!(x & (1 << i))) continue;
    for (int j = 0; j < i; ++j) {
      ans.push_back(mn);
    }
    mn += d;
    ans.push_back(mn);
    mn += d;
  }
  cout << ans.size() << '\n';
  for (auto x : ans) cout << x << ' ';
  return 0;
}
