#include <bits/stdc++.h>
using namespace std;
vector<int> preres;
void solve(int limit, int &sum, int cnt) {
  cnt = preres.size();
  vector<int> res;
  for (int i = 1; i < limit + 1; i++) {
    if (sum == 0) {
      break;
    }
    if (i & 1) {
      cnt++;
      sum -= 1;
      res.push_back(i);
    }
  }
  cout << cnt << endl;
  for (auto it : res) {
    cout << it << " ";
  }
  for (auto it : preres) {
    cout << it << " ";
  }
  return;
}
int main() {
  ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  int t = 1;
  while (t--) {
    int sum, limit;
    cin >> sum >> limit;
    int ones = (limit + 1) / 2;
    if (sum <= ones) {
      solve(limit, sum, 0);
    } else {
      vector<pair<int, int>> v;
      for (int i = 2; i <= limit; i += 2) {
        bitset<32> number = i;
        for (int j = 0; j < 32; j++) {
          if (number[j] == 1) {
            v.push_back({-1 << j, i});
            break;
          }
        }
      }
      sort((v).begin(), (v).end());
      for (auto it : v) {
        if (sum + it.first <= ones && sum + it.first >= 0) {
          preres.push_back(it.second);
          sum += it.first;
          solve(limit, sum, 0);
          break;
        } else if (sum + it.first >= 0) {
          preres.push_back(it.second);
          sum += it.first;
        }
      }
      if (sum) {
        cout << -1;
      }
    }
  }
  return 0;
}
