#include <bits/stdc++.h>
using namespace std;
long long n, k, ans, maxi;
bool used[1000005];
int main() {
  cin >> n >> k;
  ans = n * (n + 1) / 2;
  if (k < ans) return cout << -1, 0;
  maxi = (3 * n * n + ((n & 1) ? 2 * n - 1 : 2 * n)) / 4;
  if (k > maxi) {
    cout << maxi << endl;
    for (int i = 1; i <= n; i++) cout << i << ' ';
    cout << endl;
    for (int i = n; i; i--) cout << i << ' ';
    return 0;
  }
  cout << k << endl;
  for (int i = 1; i <= n; i++) cout << i << ' ';
  cout << endl;
  for (int i = n; i > (n + 1) / 2; i--) {
    if (ans + i - (n + 1 - i) <= k) {
      ans += i - (n + 1 - i);
      cout << i << ' ', used[i] = 1;
    } else {
      used[k - ans + n + 1 - i] = 1;
      cout << k - ans + n + 1 - i << ' ';
      break;
    }
  }
  for (int i = 1; i <= n; i++)
    if (!used[i]) cout << i << ' ';
  return 0;
}
