#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vd = vector<double>;
using vs = vector<string>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pdd = pair<double, double>;
using vpii = vector<pii>;
using vvpii = vector<vpii>;
using vpll = vector<pll>;
using vvpll = vector<vpll>;
using vpdd = vector<pdd>;
using vvpdd = vector<vpdd>;
template <typename T>
ostream &operator<<(ostream &o, vector<T> v) {
  if (v.size() > 0) o << v[0];
  for (unsigned i = 1; i < v.size(); i++) o << " " << v[i];
  return o << " ";
}
ll gcd(ll a, ll b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
ll lcm(ll a, ll b) { return a * b / gcd(a, b); }
ll ceeel(ll n, ll a) {
  if (n % a == 0) return n / a;
  return n / a + 1;
}
ll power(ll x, ll y) {
  ll ans = 1;
  for (ll i = (0); i < (y); i++) {
    ans *= x;
  }
  return ans;
}
ll count(ll x) {
  for (ll i = (0); i < (100); i++) {
    if (x & 1) {
      return power(2, i);
    }
    x >>= 1;
  }
}
void solve() {
  ll sum, n;
  cin >> sum >> n;
  map<ll, pair<ll, vll> > mp;
  map<ll, vll> track;
  for (ll i = (1); i < (n + 1); i++) {
    ll temp;
    temp = count(i);
    mp[temp].first++;
    mp[temp].second.push_back((i));
  }
  vll ans;
  ll elem = 0;
  for (auto it = mp.rbegin(); it != mp.rend(); it++) {
    ll cnt = 0;
    while ((*it).second.first--) {
      if (sum - (*it).first >= 0) {
        sum -= (*it).first;
        ans.push_back(((*it).second.second[cnt]));
        cnt++;
        elem++;
      } else {
        break;
      }
    }
  }
  if (sum != 0) {
    cout << "-1";
    return;
  }
  cout << elem << "\n";
  for (ll i = (0); i < (ans.size()); i++) {
    cout << ans[i] << " ";
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  solve();
  return 0;
}
