#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
int main(int argc, char* argv[]) {
  std::ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.precision(10);
  ll n, k;
  cin >> n >> k;
  vector<int> perm(n);
  iota((perm).begin(), (perm).end(), 1);
  int last = n - 1;
  ll diff = k - n * (n + 1) / 2;
  if (diff < 0) {
    cout << -1 << '\n';
    return 0;
  }
  for (int i = 0; i < last; i++) {
    if (last - i <= diff) {
      swap(perm[i], perm[last]);
      diff -= last - i;
      last--;
    }
  }
  cout << k - diff << '\n';
  for (int i = 0; i < (n); ++i) cout << i + 1 << " ";
  cout << '\n';
  for (int i = 0; i < (n); ++i) cout << perm[i] << " ";
  cout.flush();
  return 0;
}
