#include <bits/stdc++.h>
using namespace std;
int n;
long long k, le, ri, aa, lk;
int a[1000100];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> n >> k;
  le = (long long)(n) * (long long)(n + 1) / 2LL;
  for (int i = 1; i <= n; i++) {
    ri += (long long)(max(i, n - i + 1));
    a[i] = i;
  }
  if (k < le) {
    cout << "-1" << endl;
    return 0;
  }
  k = min(k, ri);
  lk = k;
  int ll = 1, rr = n;
  k -= le;
  while (1) {
    aa = (long long)(rr - ll);
    if (aa >= k) {
      swap(a[rr], a[rr - k]);
      break;
    } else {
      swap(a[ll], a[rr]);
      ll++;
      rr--;
      k -= aa;
    }
    if (ll >= rr) break;
  }
  cout << lk << endl;
  for (int i = 1; i <= n; i++) cout << i << ' ';
  cout << endl;
  for (int i = 1; i <= n; i++) cout << a[i] << ' ';
  cout << endl;
  return 0;
}
