#include <bits/stdc++.h>
using namespace std;
long long n, k;
int d[1001000];
int ans[1001000];
int main() {
  scanf("%lld%lld", &n, &k);
  int max1 = n;
  int min1 = 1;
  long long sum = 0;
  for (int i = 1; i <= n; i++) {
    d[i] = 1;
    sum += i;
  }
  long long ans1 = 0;
  if (n % 2 == 0) {
    ans1 = (n + (n + 2) / 2) * n / 2;
  } else {
    ans1 += (n + (n + 3) / 2) * ((n - 1) / 2) + (n + 1) / 2;
  }
  if (k < sum) {
    printf("-1");
  } else if (k > ans1) {
    printf("%lld\n", ans1);
    for (int i = 1; i <= n; i++) printf("%d ", i);
    printf("\n");
    for (int i = n; i >= 1; i--) printf("%d ", i);
    printf("\n");
  } else {
    long long temp = k - sum;
    for (int i = 1; i <= n; i++) ans[i] = i;
    while (temp > 0) {
      long long temp1 = min1;
      long long temp2 = max1;
      if ((temp2 - temp1) <= temp) {
        temp -= (temp2 - temp1);
        d[temp1] -= 1;
        d[temp2] += 1;
        swap(ans[temp1], ans[temp2]);
      } else {
        d[temp1 + temp] += 1;
        d[temp1] -= 1;
        swap(ans[temp1], ans[temp1 + temp]);
        temp = 0;
      }
      while (d[min1] == 0) min1 += 1;
      while (d[max1] == 2) max1 -= 1;
    }
    printf("%lld\n", k);
    for (int i = 1; i <= n; i++) printf("%d ", i);
    printf("\n");
    for (int i = 1; i <= n; i++) printf("%d ", ans[i]);
  }
  return 0;
}
