#include <bits/stdc++.h>
using namespace std;
string toBinary(int x) {
  char buffer[64];
  char* p = buffer + 64;
  do {
    *--p = '0' + (x & 1);
  } while (x >>= 1);
  return std::string(p, buffer + 64);
}
string reverse(string input) {
  string output = "";
  for (int j = input.length() - 1; j >= 0; j--) {
    output.push_back(input.at(j));
  }
  return output;
}
int pos(int bini) {
  int index = 0;
  string bin = reverse(toBinary(bini));
  for (int i = 0; i < bin.length(); i++) {
    if (bin[i] == '1') return i;
  }
  return index;
}
int main() {
  ios_base::sync_with_stdio(0);
  int sum, limit;
  cin >> sum >> limit;
  vector<int> ones;
  vector<pair<int, int> > twos;
  vector<int> ow;
  int tsum = 0;
  for (int i = 1; i <= limit; i++) {
    if (i % 2 != 0)
      ones.push_back(i);
    else {
      if (log10(i) / log10(2) == (int)(log10(i) / log10(2)))
        ow.push_back(i);
      else {
        int p = pos(i);
        pair<int, int> pp;
        pp.first = p;
        pp.second = i;
        twos.push_back(pp);
      }
    }
  }
  sort(twos.begin(), twos.end());
  sort(ow.begin(), ow.end());
  set<int> soln;
  if (!ow.empty())
    for (int i = ow.size() - 1; i >= 0; i--) {
      int pos = i;
      if (ow[pos] <= sum) {
        soln.insert(ow[pos]);
        sum -= ow[pos];
        tsum += ow[pos];
      }
    }
  if (!twos.empty())
    for (int i = twos.size() - 1; i >= 0; i--) {
      int pos = i;
      if (sum - (int)pow(2, twos[pos].first) >= 0) {
        soln.insert(twos[pos].second);
        sum -= (int)pow(2, twos[pos].first);
        tsum += (int)pow(2, twos[pos].first);
      }
    }
  if (!ones.empty())
    while (sum > 0) {
      int pos = ones.size() - 1;
      if (sum > 0 && !ones.empty()) {
        soln.insert(ones[pos]);
        sum -= 1;
        ones.pop_back();
        tsum++;
      } else
        break;
    }
  if (sum == 0 && !soln.empty()) {
    cout << soln.size() << endl;
    for (set<int>::iterator it = soln.begin(); it != soln.end(); it++) {
      cout << *it << " ";
      sum += *it;
    }
  } else
    cout << -1;
  return 0;
}
