#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
using pii = pair<int, int>;
using pll = pair<LL, LL>;
const int MAX_NR = 1e5;
int nr_used[MAX_NR + 1];
bitset<MAX_NR + 1> was_added;
string to_bin(int lim) {
  string rev_res;
  while (lim) {
    rev_res += to_string(lim % 2);
    lim /= 2;
  }
  return rev_res;
}
int get_lsb(const int &nr) { return __builtin_ctz(nr); }
int get_nr_pos(const int &bound, const int &nr) {
  return (bound + nr) / (1 << (get_lsb(nr) + 1));
}
int main() {
  cin.sync_with_stdio(0);
  int sum, limit;
  cin >> sum >> limit;
  string rev_bin_sum = to_bin(sum);
  int len_bin = rev_bin_sum.size();
  vector<int> res_set;
  for (int i = 0; i < len_bin; ++i) {
    if ((1 << i) <= limit && rev_bin_sum[i] == '1') {
      ++nr_used[1 << i];
      res_set.push_back(1 << i);
      was_added[1 << i] = true;
    } else if ((1 << i) > limit && rev_bin_sum[i] == '1') {
      vector<pii> divided = {{(1 << i) / 2, 2}};
      while (!divided.empty()) {
        int aux = divided.back().second;
        int nr_cur_pos = get_nr_pos(limit, divided.back().first);
        if (nr_cur_pos - nr_used[divided.back().first] >
            divided.back().second) {
          nr_used[divided.back().first] += divided.back().second;
          divided.back().second = 0;
        } else {
          divided.back().second -= nr_cur_pos - nr_used[divided.back().first];
          nr_used[divided.back().first] = nr_cur_pos;
        }
        aux -= divided.back().second;
        for (int j = 0, cur_nr = divided.back().first; j < aux; ++j) {
          if (cur_nr > limit) {
            cout << "-1";
            return 0;
          }
          if (was_added[cur_nr]) {
            while (was_added[cur_nr] && cur_nr <= limit) {
              cur_nr += (1 << (get_lsb(cur_nr) + 1));
            }
            if (cur_nr > limit) {
              cout << "-1";
              return 0;
            }
          }
          was_added[cur_nr] = true;
          res_set.emplace_back(cur_nr);
          cur_nr += (1 << (get_lsb(cur_nr) + 1));
        }
        if (divided.back().second == 0) {
          break;
        } else {
          pii cur_nr = divided.back();
          divided.pop_back();
          if (cur_nr.first / 2 == 0) {
            cout << "-1";
            return 0;
          }
          divided.push_back({cur_nr.first / 2, 2 * cur_nr.second});
        }
      }
    }
  }
  cout << res_set.size() << "\n";
  for (const int &nr : res_set) {
    cout << nr << " ";
  }
}
