#include <bits/stdc++.h>
using namespace std;
vector<long long int> ans;
int main() {
  long long int n, k;
  cin >> n >> k;
  long long int ans1 = 0;
  long long int ans2 = 0;
  for (long long int i = 1; i <= n; i++) {
    ans1 = ans1 + i;
  }
  for (long long int i = 1; i <= n; i++) {
    ans2 = ans2 + max(n + 1 - i, i);
  }
  if (k < ans1) {
    cout << -1 << "\n";
    return 0;
  }
  if (k >= ans2) {
    cout << ans2 << "\n";
    for (long long int i = 1; i <= n; i++) {
      cout << n + 1 - i << " ";
    }
    cout << "\n";
    for (long long int i = 1; i <= n; i++) {
      cout << i << " ";
    }
    cout << "\n";
    return 0;
  }
  cout << k << "\n";
  ans.push_back(0);
  for (long long int i = 1; i <= n; i++) {
    ans.push_back(i);
  }
  k = k - ans1;
  for (long long int i = 1; i <= (long long int)(n / 2); i++) {
    long long int tmp;
    if (k > (n + 1 - i) - i) {
      tmp = ans[n + 1 - i];
      ans[n + 1 - i] = ans[i];
      ans[i] = tmp;
      k = k - (n + 1 - i - i);
    } else {
      tmp = ans[i + k];
      ans[i + k] = ans[i];
      ans[i] = tmp;
      break;
    }
  }
  for (long long int i = 1; i <= n; i++) {
    cout << ans[i] << " ";
  }
  cout << "\n";
  for (long long int i = 1; i <= n; i++) {
    cout << i << " ";
  }
  cout << "\n";
}
