#include <bits/stdc++.h>
using namespace std;
int sol[1000000];
int main() {
  long long n, k, t1, t2;
  cin >> n >> k;
  t1 = (n * (n + 1)) / 2;
  if (t1 > k) {
    printf("-1\n");
    return 0;
  }
  int t = n - 1;
  int i = 0;
  while (t > 0) {
    if ((t1 + t) < k) {
      t1 += t;
      sol[i] = n - i;
      sol[n - 1 - i] = i + 1;
    } else {
      sol[n - i - 1 - (k - t1)] = n - i;
      sol[n - i - 1] = n - i - (k - t1);
      t1 = k;
      break;
    }
    t -= 2;
    i++;
  }
  printf("%lld\n", t1);
  for (i = 0; i < n; i++) printf("%d ", i + 1);
  printf("\n");
  for (i = 0; i < n; i++) {
    if (sol[i])
      printf("%d ", sol[i]);
    else
      printf("%d ", i + 1);
  }
  return 0;
}
