#include <bits/stdc++.h>
using namespace std;
int n, m, k;
const int maxn = 1e6 + 10;
template <class T>
inline T read() {
  int f = 1;
  T ret = 0;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    ret = (ret << 1) + (ret << 3) + ch - '0';
    ch = getchar();
  }
  ret *= f;
  return ret;
}
template <class T>
inline void write(T n) {
  if (n < 0) {
    putchar('-');
    n = -n;
  }
  if (n >= 10) {
    write(n / 10);
  }
  putchar(n % 10 + '0');
}
template <class T>
inline void writeln(const T &n) {
  write(n);
  puts("");
}
long long t[maxn];
int main(int argc, char const *argv[]) {
  n = read<int>();
  long long k = read<long long>();
  for (int i = 1; i <= n; i++) t[i] = i;
  long long cur = (1LL + n) * n / 2;
  if (k < cur) {
    puts("-1");
    return 0;
  } else {
    int l = 1, r = n;
    while (l < r) {
      int temp = r - l;
      if (cur + temp <= k) {
        cur += temp;
        swap(t[l], t[r]);
        ++l, --r;
      } else {
        int tmp = k - cur + l;
        swap(t[tmp], t[l]);
        cur += tmp - l;
        break;
      }
    }
  }
  writeln(cur);
  for (int i = 1; i <= n; i++) write(i), putchar(' ');
  puts("");
  for (int i = 1; i <= n; i++) write(t[i]), putchar(' ');
  return 0;
}
