#include <bits/stdc++.h>
using namespace std;
int min(int a, int b) {
  if (a > b) a = b;
  return a;
}
int max(int a, int b) {
  if (a < b) a = b;
  return a;
}
int lowbit(int num) {
  for (int i = 0; i < 32; i++) {
    if ((1 << i) & num) return 1 << i;
  }
}
int main() {
  int n, m, cnt = 0, num[40], x;
  bool vis[100005];
  memset(vis, false, sizeof(vis));
  scanf("%d%d", &n, &m);
  for (int i = m; i > 0; i--) {
    if (n >= lowbit(i)) {
      num[cnt++] = i;
      n -= lowbit(i);
    }
  }
  if (n != 0)
    puts("-1");
  else {
    printf("%d\n", cnt);
    for (int i = 0; i < cnt; i++) {
      printf("%d ", num[i]);
    }
  }
  return 0;
}
