#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 100;
long long n, k;
vector<int> a, b;
int adding[N];
long long f[N], s[N], temp[N], out[N];
bool cont_s[N], cont_f[N];
int main() {
  scanf("%lld %lld", &n, &k);
  long long lower = (n * (n + 1)) / 2;
  long long mid = (n + 1) / 2;
  long long min_tot = (mid * (mid + 1)) / 2;
  long long upper = 2 * (lower - min_tot) + (n & 1 ? mid : 0);
  long long ans = k;
  if (k < lower) {
    puts("-1");
    return 0;
  } else if (k >= upper) {
    ans = upper;
    for (int i = 1; i <= n; ++i) f[i - 1] = i;
    for (int i = n, k = 0; i >= 1; --i, ++k) s[k] = i;
  } else {
    long long diff = k - lower;
    for (int i = n - 1, p = n, j = 0; i >= 0; --i) {
      temp[i] = p, j++;
      if (j % 2 == 0) p--;
    }
    for (int i = 0; i < n; ++i) out[i] = i + 1;
    for (int i = n - 1; i >= 0; --i) {
      if (diff > 0) {
        long long cur = min(diff, temp[i] - out[i]);
        diff -= cur, out[i] += cur;
        if (out[i + 1] == out[i])
          s[i] = out[i], cont_s[s[i]] = true;
        else
          f[i] = out[i], cont_f[f[i]] = true;
      }
    }
    for (int i = 0, k = 1; i < n; ++i) {
      if (f[i] == 0) {
        while (cont_f[k]) k++;
        f[i] = k;
        k++;
      }
    }
    for (int i = 0, k = 1; i < n; ++i) {
      if (s[i] == 0) {
        while (cont_s[k]) k++;
        s[i] = k;
        k++;
      }
    }
  }
  printf("%lld\n", ans);
  for (int i = 0; i < n; ++i) {
    if (i != 0) printf(" ");
    printf("%lld", f[i]);
  }
  puts("");
  for (int i = 0; i < n; ++i) {
    if (i != 0) printf(" ");
    printf("%lld", s[i]);
  }
  puts("");
  return 0;
}
