#include <bits/stdc++.h>
#pragma GCC optimize(3)
using namespace std;
inline long long read() {
  char c = getchar();
  long long x = 0;
  bool f = 0;
  for (; !isdigit(c); c = getchar()) f ^= !(c ^ 45);
  for (; isdigit(c); c = getchar()) x = (x << 1) + (x << 3) + (c ^ 48);
  if (f) x = -x;
  return x;
}
long long n, m, a[1000005];
inline long long c2(long long x) { return x * (x + 1) / 2; }
inline long long ge(long long x) {
  if (x & 1) return x / 2 + 1 + 2 * (c2(x) - c2(x / 2 + 1));
  return 2 * (c2(x) - c2(x / 2));
}
signed main() {
  n = read(), m = read();
  long long lst = m;
  if (m < c2(n)) {
    puts("-1");
    return 0;
  }
  cout << min(m, ge(n)) << endl;
  for (register long long i = (1); i <= (n); ++i) a[i] = i, cout << i << " ";
  puts("");
  m -= c2(n);
  for (long long l = 1, r = n; l < r; l++, r--) {
    if (m <= r - l) {
      swap(a[l], a[l + m]);
      break;
    }
    swap(a[l], a[r]);
    m -= r - l;
  }
  for (register long long i = (1); i <= (n); ++i) cout << a[i] << " ";
  return 0;
}
