#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1234567;
int pos1[MAXN];
int pos2[MAXN];
int main() {
  long long N, K;
  scanf("%lld %lld", &N, &K);
  long long up = 0;
  for (long long i = N, cnt = N; i >= 1 && cnt; i--) {
    up += i;
    cnt--;
    if (!cnt) break;
    up += i;
    cnt--;
  }
  if (K < (N + 1) * N / 2) return !printf("-1\n");
  long long ans = min(up, K);
  printf("%lld\n", ans);
  for (int i = 1; i <= N; i++) {
    pos1[i] = pos2[i] = i;
  }
  long long mx = N;
  K -= ((N + 1) * N / 2);
  for (int i = 1; i <= N && K; i++) {
    long long need = min(mx - i, K);
    pos2[i + need] = i;
    pos2[i] = i + need;
    K -= need;
    mx--;
  }
  for (int i = 1; i <= N; i++) printf("%d ", i);
  puts("");
  for (int i = 1; i <= N; i++) printf("%d ", pos2[i]);
  puts("");
  long long check = 0;
  for (int i = 1; i <= N; i++) {
    check += max(i, pos2[i]);
  }
  if (check != ans) assert(false);
  return 0;
}
