#include <bits/stdc++.h>
using namespace std;
const long long N = 1e6 + 5;
long long n, k, maxans, min_t, max_t;
long long ans[N];
long long read() {
  long long s = 0, w = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') w = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9')
    s = (s << 3) + (s << 1) + ch - '0', ch = getchar();
  return s * w;
}
signed main() {
  n = read();
  k = read();
  min_t = (1 + n) * n / 2;
  max_t = (2 * n - n / 2 + 1) * (n / 2);
  if (n & 1) max_t += n / 2 + 1;
  if (k < min_t) {
    printf("-1");
    return 0;
  }
  if (k == min_t) {
    printf("%lld\n", min_t);
    for (long long i = 1; i <= n; ++i) printf("%lld ", i);
    printf("\n");
    for (long long i = 1; i <= n; ++i) printf("%lld ", i);
    return 0;
  }
  if (k >= max_t) {
    printf("%lld\n", max_t);
    for (long long i = 1; i <= n; ++i) printf("%lld ", i);
    printf("\n");
    for (long long i = n; i >= 1; --i) printf("%lld ", i);
    return 0;
  }
  for (long long i = 1; i <= n; ++i) ans[i] = i;
  maxans = min_t;
  k -= min_t;
  for (long long i = 1; i <= n / 2; ++i)
    if (k > n - 2 * i + 1)
      swap(ans[i], ans[n - i + 1]), k -= n - 2 * i + 1, maxans += n - 2 * i + 1;
    else {
      swap(ans[i], ans[n - i + 1 - (n - 2 * i + 1 - k)]);
      maxans += k;
      k = 0;
      break;
    }
  printf("%lld\n", maxans);
  for (long long i = 1; i <= n; ++i) printf("%lld ", i);
  printf("\n");
  for (long long i = 1; i <= n; ++i) printf("%lld ", ans[i]);
  return 0;
}
