#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e18;
const int MAX_LOG = 21;
const int MAX_N = 200005;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long n, k;
  cin >> n >> k;
  int a[n + 1];
  for (int i = 1; i <= n; i++) {
    a[i] = i;
  }
  long long mini = n * (n + 1) / 2;
  long long maxi = 0;
  for (long long i = 1; i <= n; i++) {
    maxi += max(i, n - i + 1);
  }
  if (k < mini) {
    cout << -1 << endl;
    return 0;
  } else if (k >= maxi) {
    cout << maxi << endl;
    for (int i = 1; i <= n; i++) {
      a[i] = n - i + 1;
    }
  } else {
    cout << k << endl;
    k -= mini;
    for (int i = 1; i <= n; i++) {
      long long canInc = n - 2 * i + 1;
      if (k <= canInc) {
        swap(a[i], a[i + k]);
        break;
      } else {
        k -= canInc;
        swap(a[i], a[n - i + 1]);
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    cout << i << " ";
  }
  cout << endl;
  for (int i = 1; i <= n; i++) {
    cout << a[i] << " ";
  }
  cout << endl;
}
