#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
using ll = long long;
using db = long double;
using ii = pair<int, int>;
const ll N = 2e5 + 5, LG = 17, MOD = 998244353;
const ll SQ = 450;
const long double EPS = 1e-7;
ll n;
ll k;
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> k;
  if (k < n * 1ll * (n + 1) / 2) {
    cout << -1 << '\n';
    return 0;
  }
  vector<ll> vt;
  for (ll i = 1; i < n + 1; i++) vt.push_back(i);
  ll ans = 1ll * n * (n + 1) / 2;
  vector<ll> v;
  vector<ll> lft;
  ll ptr = 0;
  for (ll i = 1; i < n + 1; i++) {
    while (!vt.empty() && vt.back() - i + ans > k) {
      lft.push_back(vt.back());
      vt.pop_back();
    }
    if (vt.empty())
      v.push_back(lft.back()), lft.pop_back();
    else
      v.push_back(vt.back()), vt.pop_back();
    ans += max(0ll, v.back() - i);
  }
  cout << ans << '\n';
  for (ll i = 1; i < n + 1; i++) cout << i << ' ';
  cout << '\n';
  for (ll i = 0; i < n; i++) cout << v[i] << ' ';
  return 0;
}
