#include <bits/stdc++.h>
using namespace std;
int p[1000005];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n, k;
  cin >> n >> k;
  long long t = k;
  k -= n * (n + 1) / 2;
  if (k < 0) {
    cout << -1;
    return 0;
  }
  int i = 1;
  while (k && i <= n / 2) {
    if (n + 1 - i * 2 <= k) {
      p[i] = n + 1 - i;
      p[n + 1 - i] = i;
      k -= n + 1 - 2 * i;
    } else {
      int b = i + k;
      p[i] = b;
      p[b] = i;
      k -= k;
    }
    i++;
  }
  cout << t - k << '\n';
  for (int i = 1; i <= n; i++) {
    cout << i << ' ';
  }
  cout << '\n';
  for (int i = 1; i <= n; i++) cout << (p[i] == 0 ? i : p[i]) << ' ';
}
