#include <bits/stdc++.h>
using namespace std;
int dictobin(int x) {
  long long counter = 0, y = x;
  while (x % 2 != 1) {
    counter++;
    x /= 2;
  }
  return pow(2, counter);
}
int main() {
  cin.tie(0);
  std::ios::sync_with_stdio(false);
  int n, m, sum = 0;
  vector<pair<int, int> > v;
  cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    v.push_back({dictobin(i), i});
  }
  sort(v.rbegin(), v.rend());
  vector<int> out;
  for (int i = 0; i < v.size(); i++) {
    if (sum + v[i].first <= n) {
      sum += v[i].first;
      out.push_back(v[i].second);
      if (sum == n) {
        cout << out.size() << endl;
        cout << out[0];
        for (int k = 1; k < out.size(); k++) cout << " " << out[k];
        cout << endl;
        return 0;
      }
    }
  }
  cout << -1 << endl;
  return 0;
}
