#include <bits/stdc++.h>
using namespace std;
template <typename T>
using min_queue = priority_queue<T, vector<T>, greater<T> >;
const long long MOD = 1e9 + 7;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  long long X, D;
  cin >> X >> D;
  vector<int> v;
  for (int i = 32; i >= 1; i--) {
    long long y = (1ll << i) - 1;
    if (y > X) continue;
    X -= y;
    v.push_back(i);
  }
  if (X) {
    for (int i = 0; i < X; i++) v.push_back(1);
  }
  long long cur = 1;
  vector<long long> res;
  for (int k : v) {
    for (int i = 0; i < k; i++) res.push_back(cur);
    cur += D;
  }
  cout << res.size() << '\n';
  for (int i = 0; i < res.size(); i++)
    cout << res[i] << ' ' << " \n"[i == res.size() - 1];
  return 0;
}
