#include <bits/stdc++.h>
using namespace std;
using namespace std;
vector<int> need;
int low_bit(int num) {
  int cur = 1;
  while (num) {
    if (num & 1) {
      return cur;
    }
    cur *= 2;
    num /= 2;
  }
}
void save_bainry(int num) {
  int cur = 1;
  while (num) {
    if (num & 1) need.push_back(cur);
    cur *= 2;
    num /= 2;
  }
}
int main() {
  int limit, sum;
  cin >> sum >> limit;
  save_bainry(sum);
  vector<pair<int, int>> bit, num;
  for (int i = 1; i <= limit; i++) bit.push_back({low_bit(i), i});
  vector<int> ans;
  reverse((need).begin(), (need).end());
  sort((bit).begin(), (bit).end());
  reverse((bit).begin(), (bit).end());
  for (auto it : need) {
    int cur = it;
    int idx = 0;
    while (idx < ((int)(bit).size())) {
      if (bit[idx].first <= cur and bit[idx].first != -1) {
        cur -= bit[idx].first;
        ans.push_back(bit[idx].second);
        bit[idx].first = -1;
      }
      idx++;
    }
    if (cur) {
      cout << "-1\n";
      exit(0);
    }
  }
  cout << ans.size() << "\n";
  for (auto it : ans) cout << it << " ";
  return 0;
}
