#include <bits/stdc++.h>
using namespace std;
int vis[1000005];
vector<int> ans;
int main() {
  long long int n, k;
  scanf("%lld %lld", &n, &k);
  if (n * (n + 1) / 2 > k) {
    printf("-1\n");
  } else {
    k = min(k, n * (n + 1) / 2 + n / 2 * (n / 2 + 1) / 2 * 2);
    k -= n * (n + 1) / 2;
    int fir = 1;
    long long int tot = 0;
    for (int i = 1, j = n; i <= n; i++) {
      while (k > 0 && j > 1 && j - i > k) {
        j--;
      }
      if (j - i < 0) k = 0;
      if (fir == 1 && k == 0) {
        j = 1;
        fir = 0;
      }
      while (k == 0 && vis[j] == 1) {
        j--;
        j = (j + 1) % n;
        j++;
      }
      ans.push_back(j);
      vis[j] = 1;
      if (k > 0 && j - i > 0) k -= j - i, tot += j - i, j--;
    }
    printf("%lld\n", tot + n * (n + 1) / 2);
    for (int i = 0; i < ans.size(); i++) {
      printf("%d ", ans[i]);
    }
    printf("\n");
    for (int i = 1; i <= n; i++) {
      printf("%d ", i);
    }
    printf("\n");
  }
  return 0;
}
