#include <bits/stdc++.h>
using namespace std;
inline int in() {
  int x, y;
  y = scanf("%d", &x);
  return x;
}
const int N = -1;
int main() {
  int X = in(), d = in();
  vector<long long> v;
  v.push_back(0);
  int b = 0;
  while (X) {
    if (X % 2) {
      v.push_back(v.back() + d);
      long long back = v.back();
      for (int j = 0; j < b; j++) v.push_back(back + d);
    }
    X /= 2;
    b++;
  }
  cout << (int)v.size() - 1 << endl;
  for (int i = 1; i < v.size(); i++) cout << v[i] << ' ';
  cout << endl;
  return 0;
}
