#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7, INF = 2e18;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long t = 1;
  while (t--) {
    long long n, k;
    cin >> n >> k;
    long long tot = (n * (n + 1)) / 2;
    if (tot > k)
      cout << "-1\n";
    else {
      long long ans = 0;
      for (long long i = 1; i <= n; i++) {
        ans += max(i, n + 1 - i);
      }
      if (ans > k) {
        cout << k << "\n";
        vector<long long> a(n);
        stack<long long> s;
        for (int i = 1; i <= n; i++) {
          cout << i << " ";
          a[i - 1] = i;
          s.push(i);
        }
        cout << "\n";
        k -= tot;
        for (int i = 0; i < n; i++) {
          long long p = s.top();
          if (p > a[i] && p - a[i] <= k) {
            k -= (p - a[i]);
            swap(a[i], a[p - 1]);
            s.pop();
          }
        }
        for (auto i : a) {
          cout << i << " ";
        }
        cout << "\n";
        ;
      } else {
        cout << ans << "\n";
        for (int i = 1; i <= n; i++) {
          cout << i << " ";
        }
        cout << "\n";
        for (int i = 1; i <= n; i++) {
          cout << n + 1 - i << " ";
        }
        cout << "\n";
      }
    }
  }
  return 0;
}
