#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 10;
int ans1[maxn];
int ans2[maxn];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  int n;
  long long k;
  cin >> n >> k;
  long long _min = (long long)n * (n + 1) / 2;
  if (_min > k) {
    puts("-1");
    return 0;
  }
  long long _max = 0;
  for (int i = 1; i <= n; i++) ans1[i] = i, ans2[i] = i;
  for (int i = 1; i <= n; i++) _max += max(i, n - i + 1);
  if (_max < k) k = _max;
  cout << k << endl;
  k -= _min;
  for (int i = 1;; i++) {
    int cur = n - i + 1 - i;
    if (k <= cur || k == 0) {
      swap(ans2[i], ans2[i + k]);
      break;
    } else
      k -= cur, swap(ans2[i], ans2[n - i + 1]);
  }
  for (int i = 1; i <= n; i++) cout << ans1[i] << " ";
  cout << '\n';
  for (int i = 1; i <= n; i++) cout << ans2[i] << " ";
  cout << '\n';
  return 0;
}
