#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long n;
  cin >> n;
  long long k;
  cin >> k;
  long long sum = (n + 1) * n / 2;
  vector<long long> a(n);
  for (long long i = 0; i < n; ++i) {
    a[i] = i + 1;
  }
  if (sum > k) {
    cout << -1;
    return;
  }
  for (long long i = 0; i < n / 2; ++i) {
    if (sum + n - 2 * i - 1 > k) {
      swap(a[i], a[i + k - sum]);
      sum = k;
    } else {
      swap(a[i], a[n - i - 1]);
      sum += n - 2 * i - 1;
    }
  }
  cout << sum << '\n';
  for (long long i = 0; i < n; ++i) cout << i + 1 << ' ';
  cout << '\n';
  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("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    solve();
    while (cin.peek() != EOF) {
      cout << "\n\n";
      solve();
    }
  } else {
    solve();
  }
}
