#include <bits/stdc++.h>
using namespace std;
const long long N = 1000 * 1000 * 3 + 20;
const long long MAX_X = 3 * 1000 + 20;
const long long MAX_N = 100 + 20;
const long long MOD = 1000 * 1000 * 1000 + 7;
const long long INF = 1000 * 1000 * 1000 + 1;
void color() { system("color a"); }
long long poww(long long x, long long y) {
  return (!y ? 1 : (y & 1 ? x * poww(x * x, y / 2) : poww(x * x, y / 2)));
}
bool flag = false;
long long n, k, keeper;
long long a[N];
void fillA() {
  for (long long i = 1; i <= n; i++) a[i] = i;
}
void solve() {
  for (long long i = 1; i <= n / 2; i++) {
    if (n + 1 - 2 * i >= k) {
      swap(a[i], a[i + k]);
      k = 0;
      break;
    } else {
      swap(a[i], a[n - i + 1]);
      k -= (n - i * 2 + 1);
    }
  }
}
void output() {
  cout << keeper - k << endl;
  for (long long i = 1; i <= n; i++) cout << i << " ";
  cout << endl;
  for (long long i = 1; i <= n; i++) cout << a[i] << " ";
}
void res() {
  fillA();
  solve();
  output();
}
signed main() {
  cin >> n >> k;
  if (k < n * (n + 1) / 2) return cout << -1, 0;
  keeper = k;
  k -= n * (n + 1) / 2;
  res();
  return 0;
}
