#include <bits/stdc++.h>
using namespace std;
int main() {
  int sum, limit;
  int a[15] = {0};
  int b[15] = {0};
  int c, t;
  bool f;
  scanf("%d %d", &sum, &limit);
  for (int i = 1; i <= limit; i++) {
    t = i;
    for (int j = 0; j < 15; j++) {
      if (t & 1) {
        ++a[j];
        break;
      }
      t >>= 1;
    }
  }
  c = 0;
  for (int j = 15 - 1; j >= 0; j--) {
    t = sum / (1 << j);
    b[j] = min(t, a[j]);
    c += b[j];
    sum -= (b[j] << j);
  }
  f = true;
  if (sum != 0) {
    printf("-1\n");
  } else {
    printf("%d\n", c);
    for (int i = 0; i < 15; i++) {
      for (int j = 0; j < b[i]; j++) {
        if (f) {
          f = false;
        } else {
          putchar(' ');
        }
        t = (1 << i) + (1 << (i + 1)) * j;
        printf("%d", t);
      }
    }
    putchar('\n');
  }
  return 0;
}
