#include <bits/stdc++.h>
const long long max9 = 10 + 1e9, max6 = 10 + 1e6, max12 = 10 + 1e12,
                max15 = 10 + 1e15;
const long long min6 = -1 * max6, min9 = -1 * max9, min12 = -1 * max12,
                min15 = -1 * max15;
const long long R = 7 + 1e9, NN = 10 + 1e5;
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long n;
  long long k;
  cin >> n >> k;
  long long mn = n * (n + 1);
  mn /= 2;
  long long nn = n / 2 - 1, mx = 2 * (nn + 1) * n - nn * (nn + 1);
  if (n % 2) mx += nn + 2;
  if (k < mn) {
    cout << -1;
    return 0;
  }
  if (k >= mx) {
    cout << mx << endl;
    for (int i = (0); i < (n); ++i) cout << i + 1 << " ";
    cout << endl;
    for (int i = (0); i < (n); ++i) cout << n - i << " ";
    return 0;
  }
  vector<int> a(n);
  long long l = 0, last = n;
  for (int i = (0); i < (n); ++i) a[i] = i + 1;
  long long ben = k - mn;
  for (int i = (0); i < (n / 2); ++i) {
    if (ben == 0) break;
    long long test = a[i] + ben;
    if (test > last) {
      a[i] = last;
      a[last - 1] = i + 1;
      ben -= last - i - 1;
      last--;
    } else {
      a[i] = test;
      a[test - 1] = i + 1;
      break;
    }
  }
  long long sum = 0;
  for (int i = (0); i < (n); ++i) sum += max(i + 1, a[i]);
  cout << sum << endl;
  for (int i = (0); i < (n); ++i) cout << i + 1 << " ";
  cout << endl;
  for (int i = (0); i < (n); ++i) cout << a[i] << " ";
  return 0;
}
