#include <bits/stdc++.h>
using namespace std;
long long read() {
  bool f = 0;
  long long x = 0;
  char c = getchar();
  while (c < '0' || '9' < c) {
    if (c == '-') f = 1;
    c = getchar();
  }
  while ('0' <= c && c <= '9')
    x = (x << 3) + (x << 1) + (c ^ 48), c = getchar();
  return !f ? x : -x;
}
int B[1000000 + 5];
int main() {
  long long n = read(), k = read(), cnt = 0;
  if ((n + 1) * n / 2 > k) {
    puts("-1");
    return 0;
  }
  for (int i = 1; i <= n; i++) B[i] = i, cnt += i;
  int pos = n;
  for (int i = 1; i < pos; i++)
    if (k >= cnt + pos - i) {
      swap(B[i], B[pos]);
      cnt += pos - i, pos--;
    }
  printf("%lld\n", cnt);
  for (int i = 1; i <= n; i++) printf("%d", i), putchar(i == n ? '\n' : ' ');
  for (int i = 1; i <= n; i++) printf("%d", B[i]), putchar(i == n ? '\n' : ' ');
  return 0;
}
