#include <bits/stdc++.h>
using namespace std;
void print(long long int** a, long long int n) {
  for (long long int i = 0; i < n; i++) {
    cout << a[i][0];
    if (i != n - 1) {
      cout << " ";
    }
  }
  cout << endl;
  for (long long int i = 0; i < n; i++) {
    cout << a[i][1];
    if (i != n - 1) {
      cout << " ";
    }
  }
}
int main() {
  long long int n;
  long long int k;
  cin >> n >> k;
  long long int min = n * (n + 1) / 2;
  if (k < min) {
    cout << "-1" << endl;
    return 0;
  }
  long long int** a = new long long int*[n];
  long long int r = 0;
  for (long long int i = 0; i < n / 2; i++) {
    r += 2 * (n - i);
    a[2 * i] = new long long int[2];
    a[2 * i][0] = n - i;
    a[2 * i][1] = i + 1;
    a[2 * i + 1] = new long long int[2];
    a[2 * i + 1][0] = i + 1;
    a[2 * i + 1][1] = n - i;
  }
  if (n % 2) {
    long long int v = ceil((float)n / 2);
    a[n - 1] = new long long int[2];
    a[n - 1][0] = v;
    a[n - 1][1] = v;
    r += v;
  }
  if (k >= r) {
    cout << r << endl;
    print(a, n);
    return 0;
  } else {
    for (long long int i = 0; i < n; i++) {
      a[i][0] = i + 1;
      a[i][1] = i + 1;
    }
    long long int maxv = n;
    long long int minv = 1;
    long long int cur = min;
    while (k - cur > maxv - minv) {
      a[maxv - 1][1] = minv;
      a[minv - 1][1] = maxv;
      cur += (maxv - minv);
      maxv -= 1;
      minv += 1;
    }
    long long int leftover = k - cur;
    long long int swp = minv + leftover;
    a[minv - 1][1] = swp;
    a[swp - 1][1] = minv;
    cout << k << endl;
    print(a, n);
    return 0;
  }
}
