#include <bits/stdc++.h>
using namespace std;
const long long maxn = 1e6 + 5;
long long a[maxn];
signed main() {
  long long n, k;
  cin >> n >> k;
  if (k < n * (n + 1) / 2) {
    cout << -1;
    return 0;
  }
  long long pt = n, sum = n * (n + 1) / 2;
  for (long long i = 1; i <= n; i++)
    if (pt > i && pt - i + sum <= k) {
      sum += pt - i;
      a[i] = pt--;
    }
  pt = 1;
  for (long long i = 1; i <= n; i++)
    if (!a[i]) a[i] = pt++;
  cout << sum << '\n';
  for (long long i = 1; i <= n; i++) cout << i << ' ';
  cout << '\n';
  for (long long i = 1; i <= n; i++) cout << a[i] << ' ';
  return 0;
}
