#include <bits/stdc++.h>
using namespace std;
int ans[100005];
struct node {
  int t;
  int w;
} limt[100005];
bool cmp(node a, node b) { return a.t < b.t; }
int main() {
  int s, l;
  cin >> s >> l;
  for (int i = 1; i <= l; i++) {
    int k = 1;
    int temp = i;
    while (temp) {
      if (temp % 2 == 1) {
        limt[i].t = k;
        limt[i].w = i;
        break;
      }
      temp /= 2;
      k *= 2;
    }
  }
  sort(limt + 1, limt + l + 1, cmp);
  int co = 0;
  int r = 0;
  for (int i = l; i > 0; i--) {
    if (co + limt[i].t <= s) {
      co += limt[i].t;
      ans[r++] = limt[i].w;
    }
  }
  if (co == s) {
    cout << r << endl;
    for (int i = 0; i < r; i++) cout << ans[i] << " ";
    cout << endl;
  } else {
    cout << -1 << endl;
  }
  return 0;
}
