#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n, t, m, i, j = 0, k = 0, l, x, y, z, f;
  long long a[1005], b[10005], sum = 0, summ = 0;
  vector<long long> v, vip, cp[1005];
  vector<int> vv, pp;
  map<long long, vector<long long>, greater<long long>> mp;
  cin >> n >> l;
  for (i = 1; i <= l; i++) {
    for (j = 0; j < 32; j++)
      if (i & (1 << j)) {
        sum += (1 << j);
        mp[(1 << j)].push_back(i);
        break;
      }
  }
  if (n > sum) {
    cout << -1;
    return;
  }
  for (auto val : mp) {
    for (j = 0; j < val.second.size(); j++)
      if (val.first <= n) {
        v.push_back(val.second[j]);
        n -= val.first;
      } else
        break;
  }
  cout << v.size() << endl;
  for (auto u : v) cout << u << " ";
}
int main() { solve(); }
