#include <bits/stdc++.h>
using namespace std;
long long x, d, now;
vector<long long> a;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> x >> d;
  now = 1;
  while (x) {
    int cnt = 2;
    while ((1 << cnt) - 1 <= x) cnt++;
    if ((1 << cnt) - 1 > x) cnt--;
    for (int i = 0; i < cnt; i++) a.push_back(now);
    now += d + 1;
    x -= (1 << cnt) - 1;
  }
  cout << a.size() << endl;
  for (int i = 0; i < a.size(); i++) cout << a[i] << " ";
  return 0;
}
