#include <bits/stdc++.h>
using namespace std;
class doi {
 public:
  void endline(char edl) { _edl = edl; }
  template <typename T>
  void o_ans(T ans[], int a, int b) {
    for (int i = a; i < b; i++) cout << ans[i] << _edl;
  }
  template <typename T>
  void o_bol(T ans[], int a, int b) {
    for (int i = a; i < b; i++) {
      if (ans[i])
        cout << "YES" << _edl;
      else
        cout << "NO" << _edl;
    }
  }
  template <typename T>
  void i_get(T arr[], int a, int b) {
    for (int i = a; i < b; i++) cin >> arr[i];
  }
  template <typename T>
  void d_reval(T arr[], T val, int a, int b) {
    for (int i = a; i < b; i++) arr[i] = val;
  }

 private:
  char _edl = '\n';
} doi;
class alg {
 public:
  int find_max(int arr[], int a, int b) {
    int tmp = -10000, ans = a;
    for (int i = a; i < b; i++) {
      if (arr[i] > tmp) {
        tmp = arr[i];
        ans = i;
      }
    }
    return ans;
  }
  int find_min(int arr[], int a, int b) {
    int tmp = 0xffff, ans = a;
    for (int i = a; i < b; i++) {
      if (arr[i] < tmp) {
        tmp = arr[i];
        ans = i;
      }
    }
    return ans;
  }
  int find_nchar(string str, char c) {
    int tmp = 0;
    for (int i = 0; i < str.size(); i++) {
      if (str[i] == c) {
        tmp++;
      }
    }
    return tmp;
  }
  string conv_lowcase(string str) {
    for (int i = 0; i < str.size(); i++) {
      if (str[i] < 96) str[i] += 32;
    }
    return str;
  }
  string conv_upcase(string str) {
    for (int i = 0; i < str.size(); i++) {
      if (str[i] > 96) str[i] -= 32;
    }
    return str;
  }
  template <typename T>
  void invert(T str[], int a) {
    int n = a / 2;
    for (int i = 0; i <= n; i++) swap(str[i], str[a - 1 - i]);
  }
  string invert(string str) {
    int n = str.size() / 2;
    for (int i = 0; i <= n; i++) swap(str[i], str[str.size() - 1 - i]);
    return str;
  }
  int base(unsigned long long int n, int k) {
    long long int tmp = 0;
    while (n >= k) {
      n /= k;
      tmp++;
    }
    return tmp;
  }
} alg;
int pow2[17];
int lowbit(int n) {
  int tmp = 0;
  while (n % 2 == 0) {
    n /= 2;
    tmp++;
  }
  return tmp;
}
int main() {
  int sum = 1, n, mnb, tmp = 0;
  vector<int> v;
  for (int i = 0; i < 17; i++) {
    pow2[i] = sum;
    sum *= 2;
  }
  cin >> sum >> n;
  while (sum && n) {
    tmp = lowbit(n);
    if (sum >= pow2[tmp]) {
      sum -= pow2[tmp];
      v.push_back(n);
    }
    n--;
  }
  if (sum > 0) {
    cout << "-1";
    return 0;
  }
  cout << v.size() << endl;
  for (int i = 0; i < v.size(); i++) {
    cout << v[i] << " ";
  }
  return 0;
}
