#include <bits/stdc++.h>
using namespace std;
priority_queue<pair<int, int> > q;
vector<int> vec;
int main() {
  ios::sync_with_stdio(false), cin.tie(0);
  int s, n;
  cin >> s >> n;
  for (int i = 1; i <= n; i++) {
    int bit = 0;
    while (!(i & (1 << bit))) bit++;
    q.push(make_pair(i, (1 << bit)));
  }
  pair<int, int> t;
  int ss = 0;
  bool f = false;
  while (!q.empty()) {
    t = q.top();
    q.pop();
    if (ss + t.second < s) {
      ss += t.second;
      vec.push_back(t.first);
    } else if (ss + t.second == s) {
      ss += t.second;
      vec.push_back(t.first);
      f = true;
      break;
    }
  }
  if (!f) return cout << -1 << endl, 0;
  cout << vec.size() << endl;
  for (int i = 0; i < vec.size(); i++) cout << vec[i] << " ";
  return 0;
}
