#include <bits/stdc++.h>
using namespace std;
vector<long long> res1;
vector<long long> res2;
void slv(long long n, long long m, long long low, long long up) {
  if (n == 0) {
    return;
  }
  if (n == 1) {
    res1.push_back(low);
    res2.push_back(up);
    return;
  }
  if (m >= (n - 1)) {
    res1.push_back(low);
    res1.push_back(up);
    res2.push_back(up);
    res2.push_back(low);
    slv(n - 2, m - (n - 1), low + 1, up - 1);
  } else {
    res1.push_back(low);
    res2.push_back(low);
    slv(n - 1, m, low + 1, up);
  }
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long n, m;
  cin >> n >> m;
  long long d;
  long long sum = 0;
  for (long long i = 1; i <= n; ++i) {
    sum += max(i, n + 1 - i);
  }
  if (m > sum) {
    m = sum;
  }
  d = m;
  for (long long i = 1; i <= n; ++i) {
    m -= i;
  }
  if (m < 0) {
    cout << (-1);
    return 0;
  }
  slv(n, m, 1, n);
  long long s = 0;
  cout << d << endl;
  for (long long i = 0; i < n; ++i) {
    cout << res1[i] << " ";
  }
  cout << endl;
  for (long long i = 0; i < n; ++i) {
    cout << res2[i] << " ";
  }
  return 0;
}
