#include <bits/stdc++.h>
using namespace std;
const int dr[] = {-1, 0, 1, 0, -1, -1, 1, 1};
const int dc[] = {0, -1, 0, 1, -1, 1, -1, 1};
const int N = 1123456;
int n, a[N], b[N];
long long k;
long long old;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> n >> k;
  old = k;
  long long sum = 0;
  for (int i = 1; i <= n; ++i) {
    a[i] = b[i] = i;
    sum += i;
  }
  if (sum > k) {
    cout << -1 << '\n';
    return 0;
  }
  k -= sum;
  for (int i = 1; i <= n / 2; ++i) {
    if (n - i * 2 + 1 <= k) {
      k -= n - i * 2 + 1;
      swap(b[i], b[n - i + 1]);
    } else {
      swap(b[i], b[i + k]);
      k = 0;
      break;
    }
  }
  cout << old - k << '\n';
  for (int i = 1; i <= n; ++i) cout << a[i] << " \n"[i == n];
  for (int i = 1; i <= n; ++i) cout << b[i] << " \n"[i == n];
  return 0;
}
