#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 10;
template <typename T>
T read() {
  T ans(0), flag(1);
  char c(getchar());
  while (!isdigit(c)) {
    if (c == '-') flag = -1;
    c = getchar();
  }
  while (isdigit(c)) {
    ans = ans * 10 + c - 48;
    c = getchar();
  }
  return ans * flag;
}
void file(string s) {
  freopen((s + ".in").c_str(), "r", stdin);
  freopen((s + ".out").c_str(), "w", stdout);
}
int n, p[maxn];
long long k;
int main() {
  cin >> n >> k;
  long long ans(0);
  for (register int i = (1), end_i = (n); i <= end_i; i++) ans += p[i] = i;
  if (k < ans) {
    printf("-1\n");
    return 0;
  }
  k -= ans;
  for (register int i = (n), end_i = (1); i >= end_i; i--)
    if (i > n - i + 1 && k) {
      long long tmp = min(i + i - n - 1ll, k);
      k -= tmp;
      ans += tmp;
      swap(p[i], p[i - tmp]);
    } else
      break;
  cout << ans << endl;
  for (register int i = (1), end_i = (n); i <= end_i; i++)
    printf("%d%c", p[i], i == n ? '\n' : ' ');
  for (register int i = (1), end_i = (n); i <= end_i; i++)
    printf("%d%c", i, i == n ? '\n' : ' ');
  return 0;
}
