#include <bits/stdc++.h>
using namespace std;
const long long N = 1000010;
long long n, k, l, r, a[N], b[N];
int main() {
  cin >> n >> k;
  for (long long i = 1; i <= n; i++) {
    l += i;
    r += max(n - i + 1, i);
  }
  if (k < l) {
    cout << -1 << endl;
    return 0;
  }
  if (k >= r) {
    cout << r << endl;
    for (long long i = 1; i <= n; i++) printf("%lld ", i);
    putchar('\n');
    for (long long i = 1; i <= n; i++) printf("%lld ", n - i + 1);
    return 0;
  }
  for (long long i = 1; i <= n; i++) a[i] = i;
  for (long long i = 1; i <= n; i++) b[i] = n - i + 1;
  long long L = 1, R = n, sum = l;
  for (long long i = 1; i <= n; i++) {
    if (R >= a[i] && sum + R - a[i] <= k) {
      sum += R - a[i];
      b[i] = R--;
    } else
      b[i] = L++;
  }
  printf("%lld\n", k);
  for (long long i = 1; i <= n; i++) printf("%lld ", a[i]);
  putchar('\n');
  for (long long i = 1; i <= n; i++) printf("%lld ", b[i]);
  return 0;
}
