#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:64000000")
using namespace std;
const long long inf64 = 1e18 + 18;
const int inf32 = 15e8;
using namespace std;
const int N = 1e4;
void solve() {
  int x, d;
  cin >> x >> d;
  long long cur = 1;
  vector<long long> ans;
  while (x) {
    int pw = 2;
    while (pw - 1 <= x) {
      ans.push_back(cur);
      pw <<= 1;
    }
    x -= (pw >> 1) - 1;
    cur += d;
  }
  cout << ans.size() << endl;
  for (auto &x : ans) cout << x << ' ';
}
int main() {
  solve();
  return 0;
}
