#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 5;
int n, arr[N];
long long k;
int main() {
  cin >> n >> k;
  long long x = 1ll * n * (n + 1) / 2;
  if (k < x) return cout << -1, 0;
  long long rem = k - x;
  set<int> all;
  for (int i = 1; i <= n; ++i) all.insert(i);
  long long ans = x;
  for (int i = 1; i <= n; ++i) {
    if (!rem) {
      arr[i] = *all.begin();
      all.erase(arr[i]);
      continue;
    }
    if (*all.rbegin() - i <= rem) {
      arr[i] = *all.rbegin();
      ans += max(0, arr[i] - i);
      rem -= max(0, arr[i] - i);
      all.erase(arr[i]);
    } else {
      int x = *all.lower_bound(rem + i);
      arr[i] = x;
      ans += max(0, x - i);
      rem -= max(0, x - i);
      all.erase(x);
    }
  }
  cout << ans << endl;
  for (int i = 1; i <= n; ++i) printf("%d ", i);
  puts("");
  for (int i = 1; i <= n; ++i) printf("%d ", arr[i]);
  return 0;
}
