#include <bits/stdc++.h>
using namespace std;
long long n, k, a[1000010];
void swap(int i, int j) {
  int temp = a[i];
  a[i] = a[j];
  a[j] = temp;
}
int main() {
  cin >> n >> k;
  long long mi = 0, ma = 0;
  for (int i = 1; i <= n; i++) {
    mi += i;
    ma += max(i * 1ll, n + 1 - i);
    a[i] = i;
  }
  if (k < mi)
    cout << -1 << endl;
  else if (k >= ma) {
    cout << ma << endl;
    for (int i = 0; i < n; i++) {
      cout << i + 1 << " ";
    }
    cout << endl;
    for (int i = 0; i < n; i++) {
      cout << n - i << " ";
    }
  } else {
    cout << k << endl;
    long long ans = mi;
    int i = 1;
    while (ans + n + 1 - 2 * i <= k) {
      ans += (n + 1 - 2 * i);
      swap(i, n - i + 1);
      i++;
    }
    for (int j = i; j <= n; j++) {
      if (j - i == (k - ans)) {
        swap(i, j);
        break;
      }
    }
    for (int i = 0; i < n; i++) {
      cout << i + 1 << " ";
    }
    cout << endl;
    for (int i = 1; i <= n; i++) {
      cout << a[i] << " ";
    }
  }
}
