#include <bits/stdc++.h>
using namespace std;
const long long N = 1e6 + 5;
long long n, k, a[N], res[N];
bool occupied[N];
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> k;
  if (k < n * (n + 1) / 2) {
    cout << -1 << endl;
    return 0;
  }
  long long delta = k - n * (n + 1) / 2;
  for (long long i = n; i >= 2; --i) {
    long long mx = 2 * i - n - 1;
    if (mx <= 0) break;
    if (mx < delta) {
      delta -= mx;
      a[i] = n - i + 1;
      res[n - i + 1] = i;
    } else {
      long long id = n - i + 1 + mx - delta;
      res[id] = i;
      a[i] = id;
      break;
    }
  }
  long long cur = 1;
  for (long long i = 1; i <= n; ++i)
    if (!res[i]) {
      while (a[cur]) cur++;
      res[i] = cur;
      cur++;
    }
  long long ans = 0;
  for (long long i = 1; i <= n; ++i) {
    ans += max(i, res[i]);
  }
  cout << ans << endl;
  for (long long i = 1; i <= n; ++i) cout << i << ' ';
  cout << endl;
  for (long long i = 1; i <= n; ++i) cout << res[i] << ' ';
  return 0;
}
