#include <bits/stdc++.h>
using namespace std;
template <class T>
inline T sqr(T x) {
  return x * x;
}
const double EPS = 1e-6;
const int INF = 0x3fffffff;
const long long LINF = INF * 1ll * INF;
const double PI = acos(-1.0);
int a[1000005], b[1000005];
int main() {
  int n;
  long long k;
  scanf("%d%lld", &n, &k);
  long long sum = 1LL * n * (n + 1) / 2;
  if (k < sum) {
    puts("-1");
    return 0;
  }
  for (int i = 1; i <= n; i++) a[i] = b[i] = i;
  for (int i = 1; i <= n / 2; i++) {
    long long d = n - i + 1 - i;
    if (sum + d <= k) {
      sum += d;
      swap(b[i], b[n - i + 1]);
    } else {
      long long tmp = k - sum;
      sum += tmp;
      swap(b[i], b[i + tmp]);
    }
  }
  printf("%lld\n", sum);
  for (int i = 1; i <= n; i++) printf("%d%c", a[i], (i == n ? '\n' : ' '));
  for (int i = 1; i <= n; i++) printf("%d%c", b[i], (i == n ? '\n' : ' '));
  return 0;
}
