#include <bits/stdc++.h>
using namespace std;
template <class T>
void dbs(string str, T t) {
  cerr << str << " : " << t << "\n";
}
template <class T, class... S>
void dbs(string str, T t, S... s) {
  long long idx = str.find(',');
  cerr << str.substr(0, idx) << " : " << t << ", ";
  dbs(str.substr(idx + 1), s...);
}
template <class S, class T>
ostream& operator<<(ostream& os, const pair<S, T>& p) {
  return os << "(" << p.first << ", " << p.second << ")";
}
template <class T>
ostream& operator<<(ostream& os, const vector<T>& p) {
  os << "[ ";
  for (auto& it : p) os << it << " ";
  return os << "]";
}
template <class T>
ostream& operator<<(ostream& os, const set<T>& p) {
  os << "[ ";
  for (auto& it : p) os << it << " ";
  return os << "]";
}
template <class S, class T>
ostream& operator<<(ostream& os, const map<S, T>& p) {
  os << "[ ";
  for (auto& it : p) os << it << " ";
  return os << "]";
}
template <class T>
void prc(T a, T b) {
  cerr << "[";
  for (T i = a; i != b; ++i) {
    if (i != a) cerr << ", ";
    cerr << *i;
  }
  cerr << "]\n";
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long t, i, j, k, n, m, q;
  long long x, y, l, r;
  cin >> n >> k;
  long long mn = n * (n + 1) / 2;
  if (k < mn) {
    cout << -1 << endl;
    return 0;
  }
  long long sum = 0;
  for (long long i = 1; i <= n / 2; i++) {
    sum += 2 * (n - i + 1);
  }
  if (n % 2) sum += (n + 1) / 2;
  k = min(k, sum);
  cout << k << endl;
  k -= mn;
  set<long long> s;
  for (long long i = 1; i <= n; i++) {
    s.insert(i);
    cout << i << " ";
  }
  cout << endl;
  long long cur = 1;
  while (k > 0) {
    if (s.find(k + cur) != s.end()) {
      cout << k + cur << " ";
      s.erase(k + cur);
      k = 0;
    } else {
      long long x = *s.rbegin();
      cout << x << " ";
      s.erase(x);
      k -= (x - cur);
    }
    cur++;
  }
  for (long long i = 1; i <= n - cur + 1; i++) {
    cout << *s.begin() << " ";
    s.erase(s.begin());
  }
  cout << endl;
  return 0;
}
