#include <bits/stdc++.h>
using namespace std;
unsigned long long mod = 1e9 + 7;
long long MOD = 998244353;
unsigned long long ncr(long long n, long long k) {
  if (k > n) return 1ll * 0;
  unsigned long long res = 1;
  if (k > n - k) k = n - k;
  for (long long i = 0; i < k; ++i) {
    res *= (n - i);
    res /= (i + 1);
    res = res;
  }
  return res;
}
bool prime(unsigned long long num) {
  bool flag = true;
  for (unsigned long long i = 2; i * i <= num; i++) {
    if (num % i == 0) {
      flag = false;
      break;
    }
  }
  return flag;
}
long long ipow(long long base, long long exp) {
  if (exp == 0) return 1ll * 1;
  long long result = 1;
  for (;;) {
    if (exp & 1) {
      result *= base;
      result = result % MOD;
    }
    exp >>= 1;
    if (!exp) break;
    base *= base;
    base = base % MOD;
  }
  return result % MOD;
}
long long abs(long long a, long long b) {
  if ((a - b) > 0)
    return (a - b);
  else
    return (b - a);
}
long long add(long long a, long long b) {
  a += b;
  if (a >= MOD)
    a -= MOD;
  else if (a < 0)
    a += MOD;
  return a;
}
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long der(long long k) {
  long long res = 0;
  long long fact = 1;
  for (long long i = 2; i <= k; i++) fact *= i;
  long long s = 1;
  long long j = 1;
  for (long long i = 2; i <= k; i++) {
    j = j * i;
    long long first = (fact / j) * s;
    res += first;
    s = s * (-1);
  }
  return res;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long x, d;
  cin >> x >> d;
  long long beg = 1;
  vector<long long> v;
  for (int i = 0; i < 31; i++) {
    long long res = x & beg;
    if (res != 0) {
      v.push_back(i);
    }
    beg = beg * 2;
  }
  beg = 1;
  vector<long long> ans;
  for (int i = 0; i < v.size(); i++) {
    int val = v[i];
    for (int j = 0; j < val; j++) {
      ans.push_back(beg);
    }
    beg += d + 1;
  }
  for (int i = 0; i < v.size(); i++) {
    ans.push_back(beg);
    beg += d + 1;
  }
  cout << ans.size() << endl;
  for (long long i = 0; i < ans.size(); i++) cout << ans[i] << " ";
}
