#include <bits/stdc++.h>
using namespace std;
string binary(int x) {
  string s = "";
  while (x) {
    if (x & 1)
      s = "1" + s;
    else
      s = "0" + s;
    x /= 2;
  }
  return s;
}
int main() {
  std::ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  int n, sum;
  cin >> n >> sum;
  vector<pair<int, int> > a;
  int total = 0;
  for (int i = 1; i <= sum; i++) {
    int k = (i & -i);
    total += k;
    if (k != 1) a.push_back({k, i});
  }
  sort(a.rbegin(), a.rend());
  if (total < n) {
    cout << -1;
    return 0;
  }
  vector<int> ans;
  int co = (sum + 1) / 2, od = 1;
  if (n <= co) {
    while (n > 0) {
      ans.push_back(od);
      od += 2;
      n--;
    }
  } else
    for (int i = 0; i < a.size(); i++) {
      n -= a[i].first;
      ans.push_back(a[i].second);
      if (n <= co) {
        while (n > 0) {
          ans.push_back(od);
          od += 2;
          n--;
        }
        break;
      }
    }
  cout << ans.size() << "\n";
  for (auto i : ans) cout << i << " ";
  return 0;
}
