#include <bits/stdc++.h>
using namespace std;
vector<int> pp[20];
int cnt[20];
int main() {
  int lim, sm;
  cin >> sm >> lim;
  for (int i = 1; i <= lim; i++) {
    for (int j = 0; j < 20; j++) {
      if (i & (1 << j)) {
        pp[j].push_back(i);
        break;
      }
    }
  }
  int cur = 19, siz = 0;
  while (sm > 0 && cur >= 0) {
    while (pp[cur].size() > cnt[cur] && sm >= (1 << cur)) {
      sm -= 1 << cur;
      cnt[cur]++;
      siz++;
    }
    cur--;
  }
  if (sm)
    cout << -1;
  else {
    cout << siz << endl;
    cur = 0;
    for (int i = 0; i < 19; i++) {
      for (int j = 0; j < cnt[i]; j++) {
        cout << pp[i][j] << " ";
      }
    }
  }
  return 0;
}
