#include <bits/stdc++.h>
using namespace std;
long long n, k, res, ans[1010101];
queue<long long> q;
stack<long long> st;
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> k;
  for (long long i = 1; i <= n; ++i) {
    st.push(i);
    q.push(i);
    k -= i;
    res += i;
  }
  if (k < 0) {
    cout << -1;
    return 0;
  }
  while (!st.empty() && !q.empty()) {
    long long vt1 = st.top(), vt2 = q.front();
    if (vt2 > vt1) break;
    if (k < vt1 - vt2) {
      st.pop();
      ans[vt1] = vt1;
    } else {
      ans[vt1] = vt2;
      ans[vt2] = vt1;
      k -= vt1 - vt2;
      res += vt1 - vt2;
      st.pop();
      q.pop();
    }
  }
  cout << res << '\n';
  for (long long i = 1; i <= n; ++i) cout << ans[i] << " ";
  cout << '\n';
  for (long long i = 1; i <= n; ++i) cout << i << " ";
}
