#include <bits/stdc++.h>
using namespace std;
using namespace std;
const long long int mod = 1e9 + 9;
const long long int mod2 = 1e9 + 9;
const long long int maxn = 2e5 + 5;
const long long int maxn1 = 1e7 + 1;
const int root = 1e6 + 5;
const long long inf = 1e18 + 18;
double pie4 = 3.1415926535;
long long int a[maxn];
vector<long long int> ans1, ans2;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int n, k, mn_sum, mx_sum, curr_sum, i, j;
  string s;
  cin >> n >> k;
  long long int x = n / 2;
  if (n % 2 == 1) x++;
  mn_sum = (n * (n + 1)) / 2;
  mx_sum = (n * (n + 1)) / 2 - (x * (x + 1)) / 2;
  if (n % 2 == 1)
    mx_sum = 2 * mx_sum + x;
  else
    mx_sum = 2 * mx_sum;
  k = min(mx_sum, k);
  curr_sum = mn_sum;
  if (k < mn_sum) {
    cout << "-1" << endl;
    exit(0);
  }
  cout << k << endl;
  ans1.push_back(0);
  ans2.push_back(0);
  for (i = 1; i <= n; i++) {
    ans1.push_back(i);
    ans2.push_back(i);
  }
  i = 1, j = n;
  while (curr_sum < k) {
    if (curr_sum + j - i <= k) {
      swap(ans2[i], ans2[j]);
      curr_sum += (j - i);
      i++;
      j--;
    } else {
      swap(ans2[j], ans2[j - (k - curr_sum)]);
      break;
    }
  }
  for (i = 1; i <= n; i++) cout << ans1[i] << " ";
  cout << endl;
  for (i = 1; i <= n; i++) cout << ans2[i] << " ";
  cout << endl;
}
