#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long n;
  std::cin >> n;
  long long k;
  std::cin >> k;
  if ((n + 1) * n / 2 > k) {
    cout << -1;
    return;
  }
  long long s = 0;
  for (long long i = 0; i < n / 2; i++) s += n - i;
  for (long long i = 0; i < n - n / 2; i++) s += n / 2 + 1 + i;
  if (s <= k) {
    cout << s << '\n';
    for (long long i = 0; i < n; i++) cout << i + 1 << ' ';
    cout << '\n';
    for (long long i = 0; i < n; i++) cout << n - i << ' ';
    cout << '\n';
    return;
  }
  cout << k << '\n';
  k -= n * (n + 1) / 2;
  for (long long i = 0; i < n; i++) cout << i + 1 << ' ';
  cout << '\n';
  std::vector<long long> a(n);
  iota(a.begin(), a.end(), 1);
  for (long long i = 0; i < n; i++) {
    if (k == 0) break;
    if (n - 1 - i * 2 <= k) {
      swap(a[i], a[n - 1 - i]);
      k -= n - 1 - i * 2;
    } else {
      swap(a[i], a[i + k]);
      break;
    }
  }
  for (long long i = 0; i < n; i++) cout << a[i] << ' ';
}
signed main(signed argc, char **argv) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  if (argc > 1 && (string)argv[1] == "local") {
    freopen("output.txt", "w", stdout);
    freopen("input.txt", "r", stdin);
  }
  solve();
  return 0;
}
