#include <bits/stdc++.h>
using namespace std;
long long int val[1000001];
vector<long long int> vect;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int n, k;
  cin >> n >> k;
  long long int tot = (n * (n + 1)) / 2;
  if (k < tot) {
    cout << "-1";
    return 0;
  }
  long long int tmp = tot;
  if ((n % 2) != 0)
    tot += (((n / 2) + 1) * ((n / 2) + 1)) - ((n / 2) + 1);
  else
    tot += (n / 2) * (n / 2);
  if (k > tot) k = tot;
  cout << k << "\n";
  for (long long int i = 1; i <= n; ++i) cout << i << " ";
  cout << "\n";
  k -= (n * (n + 1)) / 2;
  for (long long int i = n; i >= 1; --i) {
    if (k == 0) break;
    if ((i - (n + 1 - i)) <= k) {
      val[n + 1 - i] = i;
      vect.push_back(n + 1 - i);
      k -= (i - (n + 1 - i));
    } else {
      val[i - k] = i;
      vect.push_back(i - k);
      k = 0;
    }
  }
  long long int sz = vect.size();
  tmp = 0;
  for (long long int i = n; i >= 1; --i) {
    if (val[i] == 0) {
      if (tmp < sz)
        val[i] = vect[tmp++];
      else
        val[i] = i;
    }
  }
  for (long int i = 1; i <= n; ++i) cout << val[i] << " ";
  return 0;
}
