#include <bits/stdc++.h>
using namespace std;
int sum, n, arr[100005], low[100005], now, has;
vector<int> ans;
vector<pair<int, int> > v;
int main() {
  cin >> sum >> n;
  low[1] = 1;
  for (int i = 2; i <= n; i++) {
    int k = __builtin_popcount(i);
    if (k == 1)
      low[i] = i, now = i;
    else
      low[i] = low[i - now];
  }
  for (int i = 1; i <= n; i++) {
    has += low[i];
    arr[low[i]]++;
    v.push_back(make_pair(low[i], i));
  }
  if (has < sum) {
    cout << "-1" << endl;
    return 0;
  }
  sort(v.begin(), v.end());
  int p = v.size();
  for (int i = p - 1; i >= 0; i--) {
    if (sum >= v[i].first) {
      ans.push_back(v[i].second);
      sum -= v[i].first;
    }
    if (sum == 0) break;
  }
  if (sum != 0) {
    cout << "-1" << endl;
    return 0;
  } else {
    cout << ans.size() << endl;
    for (int i = 0; i < ans.size(); i++) {
      cout << ans[i] << " ";
    }
    cout << endl;
  }
}
