#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 100;
int pos[maxn];
int main() {
  int n;
  long long k;
  cin >> n >> k;
  long long l = 1LL * (n + 1) * n / 2;
  long long r = 2 * l - 1LL * (n / 2 + 1) * (n / 2);
  if (n & 1) r -= n / 2 + 1;
  if (k < l) {
    cout << -1 << endl;
  } else {
    if (k >= r) {
      cout << r << endl;
      for (int i = 1; i <= n; ++i) {
        pos[i] = i;
        cout << i << " ";
      }
      cout << endl;
      for (int i = 1; i <= n; ++i) {
        if (i <= n / 2) {
          swap(pos[i], pos[n - i + 1]);
          cout << pos[i] << ' ';
        } else
          cout << pos[i] << " ";
      }
      cout << endl;
      return 0;
    }
    cout << k << endl;
    for (int i = 1; i <= n; ++i) pos[i] = i;
    k -= l;
    int ll = 1, rr = n;
    while (k) {
      long long tmp = min(ll + k, 1LL * rr);
      swap(pos[ll], pos[tmp]);
      k -= tmp - ll;
      ++ll;
      --rr;
    }
    for (int i = 1; i <= n; ++i) {
      cout << i << " ";
    }
    cout << endl;
    for (int i = 1; i <= n; ++i) {
      cout << pos[i] << " ";
    }
    cout << endl;
  }
  return 0;
}
