#include <bits/stdc++.h>
using namespace std;
int ans[100000 + 100];
int lowbit(int i) { return i & (-i); }
struct date {
  int index;
  int da;
} a[100000 + 100];
bool cmp(struct date& a1, struct date& a2) {
  if (a1.da != a2.da)
    return a1.da < a2.da;
  else
    return a1.index < a2.index;
}
int main() {
  memset(a, 0, sizeof(a));
  int sum, l;
  cin >> sum >> l;
  for (int i = 1; i <= l; i++) {
    a[i].da = lowbit(i);
    a[i].index = i;
  }
  sort(a + 1, a + 1 + l, cmp);
  int k = 0;
  for (int i = l; i >= 1; i--) {
    if (sum >= a[i].da) {
      ans[++k] = a[i].index;
      sum -= a[i].da;
    }
  }
  if (sum == 0) {
    cout << k << endl;
    for (int i = 1; i <= k; i++) printf("%d ", ans[i]);
  } else
    cout << -1 << endl;
  return 0;
}
