#include <bits/stdc++.h>
using namespace std;
template <typename T>
istream &operator>>(istream &is, vector<T> &arr);
template <typename T>
ostream &operator<<(ostream &os, vector<T> &arr);
int INF = 1e9 + 5;
void nope() {
  cout << -1 << endl;
  exit(0);
}
int main() {
  int sum, limit;
  cin >> sum >> limit;
  vector<vector<int>> bitMap(32, vector<int>());
  for (int i = 1; i <= limit; i++) {
    int j = 0;
    while (j < 31 && ((i & (1 << j)) == 0)) j++;
    bitMap[j].push_back(i);
  }
  int iter = 30;
  vector<int> ans;
  while (sum > 0 && iter >= 0) {
    if (sum < (1 << iter))
      iter--;
    else {
      if (bitMap[iter].size() == 0)
        iter--;
      else {
        int tf = bitMap[iter][bitMap[iter].size() - 1];
        ans.push_back(tf);
        bitMap[iter].pop_back();
        sum -= (1 << iter);
      }
    }
  }
  if (sum != 0)
    cout << -1 << endl;
  else {
    cout << (int)ans.size() << endl;
    for (int i : ans) cout << i << ' ';
    cout << endl;
  }
}
template <typename T>
istream &operator>>(istream &is, vector<T> &arr) {
  typename vector<T>::iterator a;
  for (a = arr.begin(); a != arr.end(); a++) {
    is >> *a;
  }
  return is;
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> &arr) {
  typename vector<T>::iterator a;
  for (a = arr.begin(); a != arr.end(); a++) {
    os << *a << " ";
  }
  os << endl;
  return os;
}
