#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-6;
void __print(int x) { cerr << x; }
void __print(long x) { cerr << x; }
void __print(long long x) { cerr << x; }
void __print(unsigned x) { cerr << x; }
void __print(unsigned long x) { cerr << x; }
void __print(unsigned long long x) { cerr << x; }
void __print(float x) { cerr << x; }
void __print(double x) { cerr << x; }
void __print(long double x) { cerr << x; }
void __print(char x) { cerr << '\'' << x << '\''; }
void __print(const char *x) { cerr << '\"' << x << '\"'; }
void __print(const string &x) { cerr << '\"' << x << '\"'; }
void __print(bool x) { cerr << (x ? "true" : "false"); }
template <typename T, typename V>
void __print(const pair<T, V> &x) {
  cerr << '{';
  __print(x.first);
  cerr << ',';
  __print(x.second);
  cerr << '}';
}
template <typename T>
void __print(const T &x) {
  int f = 0;
  cerr << '{';
  for (auto &i : x) cerr << (f++ ? "," : ""), __print(i);
  cerr << "}";
}
void _print() { cerr << "]\n"; }
template <typename T, typename... V>
void _print(T t, V... v) {
  __print(t);
  if (sizeof...(v)) cerr << ", ";
  _print(v...);
}
long long lool(long long n) {
  for (long long i = 0;; i++) {
    if (n & (1 << i)) return 1 << i;
  }
}
void solve() {
  long long s, l;
  cin >> s >> l;
  long long i, j;
  std::vector<pair<long long, long long>> v;
  std::vector<long long> ans;
  for (i = 1; i <= l; i++) {
    v.push_back({lool(i), i});
  }
  sort(v.rbegin(), v.rend());
  for (auto it : v) {
    if (s >= it.first) {
      s -= it.first;
      ans.push_back(it.second);
    }
  }
  if (s) {
    cout << -1;
    return;
  }
  cout << ans.size() << '\n';
  for (i = 0; i < ans.size(); i++) cout << ans[i] << " ";
}
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  ;
  long long t = 1;
  while (t--) solve();
}
