#include <bits/stdc++.h>
using namespace std;
mt19937_64 rang(
    chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int lim) {
  uniform_int_distribution<int> uid(0, lim - 1);
  return uid(rang);
}
const int INF = 0x3f3f3f3f;
const int mod = 1e9 + 7;
void solve() {
  int sum, limit;
  cin >> sum >> limit;
  vector<int> res;
  for (int i = limit; i >= 1; i--) {
    int lowbit = i ^ (i & (i - 1));
    if (sum >= lowbit) res.push_back(i), sum -= lowbit;
    if (sum == 0) break;
  }
  if (sum != 0)
    cout << -1;
  else {
    cout << res.size() << "\n";
    for (auto x : res) cout << x << " ";
  }
}
int main() {
  ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
  srand(chrono::high_resolution_clock::now().time_since_epoch().count());
  int t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
