#include <bits/stdc++.h>
using namespace std;
void ram5564() {
  long long sum, limit;
  cin >> sum >> limit;
  pair<long long, long long> p[limit + 1];
  for (long long i = 1; i <= limit; ++i) {
    for (long long j = 0; j <= 31; ++j) {
      if (i & (1 << j)) {
        long long sum = pow(2, j);
        p[i].first = sum;
        p[i].second = i;
        break;
      }
    }
  }
  sort(p + 1, p + limit + 1);
  reverse(p + 1, p + limit + 1);
  vector<long long> v;
  for (long long i = 1; i <= limit; ++i) {
    if (sum >= p[i].first) {
      v.push_back(p[i].second);
      sum -= p[i].first;
    }
  }
  if (v.size() == -1 || sum > 0) {
    cout << -1;
    return;
  }
  cout << v.size() << "\n";
  for (long long i = 0; i < v.size(); i++) cout << v[i] << " ";
  cout << "\n";
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long t = 1;
  while (t--) ram5564();
  return 0;
}
