#include <bits/stdc++.h>
using namespace std;
long long n, k, sum, ck[1000005], mk;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n >> k;
  if (k < (n + 1) * n / 2) {
    cout << -1;
    return 0;
  }
  if (n % 2 == 0) {
    for (int i = n; i > n / 2; i--) sum += i;
    sum *= 2;
  } else {
    for (int i = n; i > n / 2; i--) sum += i;
    sum = sum * 2 - (n / 2 + 1);
  }
  cout << min(k, sum) << "\n";
  mk = min(sum, k) - n * (n + 1) / 2;
  for (int i = 1; i <= n; i++) cout << i << " ";
  cout << "\n";
  long long cnt = n, st = 1;
  for (int i = 1; i <= n; i++) {
    if (mk > 0 && cnt >= i) {
      if (cnt - i <= mk)
        cout << cnt << " ", ck[cnt] = 1, mk -= cnt - i, cnt--;
      else {
        while (cnt - i > mk || ck[cnt] == 1) cnt--;
        cout << cnt << " ", ck[cnt] = 1, mk -= (cnt - i), cnt--;
      }
    } else {
      if (!ck[st])
        cout << st << " ", st++;
      else {
        while (ck[st]) st++;
        cout << st << " ", st++;
      }
    }
  }
  return 0;
}
