#include <bits/stdc++.h>
using namespace std;
long long mod = 1e9 + 7;
long long Bpow(long long a, long long s) {
  if (s == 0) {
    return 1;
  }
  long long u = Bpow(a, s / 2);
  if (s & 1)
    return u * u % mod * a % mod;
  else
    return u * u % mod;
}
int32_t main() {
  long long n, k;
  cin >> n >> k;
  if (n * (n + 1) / 2 > k) {
    cout << "-1";
    return 0;
  }
  vector<long long> ans(n + 1);
  long long snow = n * (n + 1) / 2;
  iota(ans.begin(), ans.end(), 0);
  for (long long i = n; i > n / 2; i--) {
    if (snow + i - (n - i + 1) > k) {
      long long ind = i - k + snow;
      swap(ans[ind], ans[i]);
      snow = k;
      break;
    } else {
      snow += i - (n - i + 1);
      swap(ans[i], ans[n - i + 1]);
    }
  }
  cout << snow << "\n";
  for (long long i = 1; i < n + 1; i++) {
    cout << i << " ";
  }
  cout << "\n";
  for (long long i = 1; i < n + 1; i++) {
    cout << ans[i] << " ";
  }
}
