#include <bits/stdc++.h>
using namespace std;
long long GCD(long long A, long long B) {
  if (B == 0) return A;
  return GCD(B, A % B);
}
long long powr(long long a, long long p, long long m) {
  if (p == 0) return 1;
  if (p % 2 == 0) {
    long long x = powr(a, p / 2, m);
    return (x * x) % m;
  }
  return (a * powr(a, p - 1, m)) % m;
}
long long low[100010];
long long ans[100010];
long long pow2[30];
long long visited[100010];
int main() {
  long long sum, limit, i, j, cop, r, val, v = 0, u = 0, lim;
  pow2[0] = 1;
  for (i = 1; i < 30; i++) pow2[i] = pow2[i - 1] * 2;
  low[0] = 0;
  for (i = 1; i < 100010; i++) {
    cop = i;
    val = 1;
    while (cop > 0) {
      r = cop % 2;
      if (r == 1) break;
      val = val * 2;
      cop = cop / 2;
    }
    low[i] = val;
    visited[i] = 0;
  }
  cin >> sum >> limit;
  cop = sum;
  for (i = limit; i > 2; i--) {
    if (low[i] <= cop && low[i] > 2) {
      cop -= low[i];
      ans[v] = i;
      v++;
      visited[i] = 1;
    }
  }
  for (i = limit; i >= 1; i--) {
    if (low[i] <= cop && low[i] == 2 && visited[i] == 0) {
      cop -= low[i];
      ans[v] = i;
      v++;
      visited[i] = 1;
    }
  }
  for (i = limit; i >= 1; i--) {
    if (low[i] <= cop && low[i] == 1 && visited[i] == 0) {
      cop -= low[i];
      ans[v] = i;
      v++;
      visited[i] = 1;
    }
  }
  if (cop > 0)
    cout << "-1" << endl;
  else {
    cout << v << endl;
    for (i = 0; i < v; i++) cout << ans[i] << " ";
    cout << endl;
  }
  return 0;
}
