#include <bits/stdc++.h>
const long long sze = 1e4 + 10, psze = 30, INF = 1e18;
using namespace std;
long long bin_pow(long long a, long long b) {
  long long res = 1;
  while (b) {
    if (b & 1 == 1) {
      res *= a;
    }
    a *= a;
    b /= 2;
  }
  return res;
}
long long bin_pow(long long a, long long b, long long p) {
  long long res = 1;
  while (b) {
    if (b & 1 == 1) {
      res *= a % p;
    }
    a *= a % p;
    b /= 2;
  }
  return res;
}
vector<long long> vertices[sze];
vector<char> visit(sze);
vector<long long> dp(sze, 0);
vector<long long> arr;
long long a[sze];
long long b[sze];
long long blnc[sze];
long long tdp[200][200];
bool did_dp[101][101];
bool checker[sze];
long long n;
long long m;
long long k;
long long cnt = 0;
double logr(long long n, long long k) { return double(log(n) / log(k)); }
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long x, d;
  cin >> x >> d;
  long long ans = 1;
  while (x > 0) {
    long long k = 1;
    long long a = 2;
    while (a - 1 <= x) {
      if (a * 2 > x + 1) break;
      a *= 2;
      k++;
    }
    for (long long i = 0; i < k; i++) {
      arr.push_back(ans);
    }
    x++;
    x -= a;
    ans += d;
  }
  cout << arr.size() << endl;
  for (long long i = 0; i < arr.size(); i++) {
    cout << arr[i] << " ";
  }
  return 0;
}
