#include <bits/stdc++.h>
using namespace std;
const int maxn = (int)2e5 + 10;
int init[maxn], cnt[maxn];
int sum, limit, ans;
int lowbit(int x) { return x & (-x); }
bool find(int u) {
  if (cnt[u]) {
    cnt[u] -= 1;
    ans += 1;
    return 1;
  }
  if (u == 1) return 0;
  if (find(u >> 1) == 0) return 0;
  if (find(u >> 1) == 0) return 0;
  return 1;
}
int main() {
  scanf("%d%d", &sum, &limit);
  for (int i = 1; i <= limit; i++) {
    int val = lowbit(i);
    init[val] += 1;
    cnt[val] += 1;
  }
  for (int i = 20; i >= 0; i--)
    if ((sum >> i) & 1) {
      if (find(1 << i) == 0) {
        puts("-1");
        return 0;
      }
    }
  printf("%d\n", ans);
  for (int i = 1; i <= limit; i++) {
    int val = lowbit(i);
    if (cnt[val] != init[val]) {
      printf("%d ", i);
      cnt[val] += 1;
    }
  }
  return 0;
}
