#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000 * 1000 * 1000 + 7;
const long long INF = 1ll * 1000 * 1000 * 1000 * 1000 * 1000 * 1000 + 7;
const long long MOD2 = 998244353;
const long long N = 101010;
const long long N2 = 1000 * 1000;
const long double PI = 3.14159265;
long long _gcd(long long a, long long b) {
  if (!b) return a;
  return _gcd(b, a % b);
}
long long power(long long x, long long y, long long p) {
  long long res = 1;
  x %= p;
  while (y > 0) {
    if (y & 1) res = (res * x) % p;
    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n, k;
  cin >> n >> k;
  long long small = (n * (n + 1)) / 2, big(0);
  for (int i = (n / 2) + 1; i <= n; ++i) {
    big += 2 * i;
  }
  if (n % 2) {
    big -= (n / 2);
    big--;
  }
  if (k < small)
    cout << -1;
  else if (k >= big) {
    cout << big << "\n";
    for (int i = 0; i < n; ++i) {
      cout << i + 1 << " ";
    }
    cout << "\n";
    for (int i = 0; i < n; ++i) {
      cout << n - i << " ";
    }
  } else {
    long long surplus = k - small;
    int ans[2][n];
    for (int i = 0; i < n; ++i) {
      ans[0][i] = i + 1;
      ans[1][i] = i + 1;
    }
    int idx = 0;
    while (surplus > 0) {
      if (surplus >= (n - (2 * idx) - 1)) {
        swap(ans[1][idx], ans[1][n - idx - 1]);
        surplus -= n - (2 * idx) - 1;
        idx++;
      } else {
        swap(ans[1][idx], ans[1][idx + surplus]);
        break;
      }
    }
    long long dum = 0;
    cout << k << "\n";
    for (int i = 0; i < n; ++i) {
      cout << ans[0][i] << " ";
      dum += max(ans[0][i], ans[1][i]);
    }
    cout << "\n";
    for (int i = 0; i < n; ++i) {
      cout << ans[1][i] << " ";
    }
  }
  return 0;
}
