#include <bits/stdc++.h>
using namespace std;
using LL = long long;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  LL n, k;
  cin >> n >> k;
  LL sum = (1 + n) * n / 2;
  if (k < sum) {
    cout << -1 << endl;
    return 0;
  }
  k -= sum;
  vector<LL> ans;
  for (LL i = n; i >= (n + 1) / 2 + 1; --i) {
    if (k > n - 1 - (n - i) * 2) {
      ans.push_back(i);
      k -= n - 1 - (n - i) * 2;
      sum += n - 1 - (n - i) * 2;
      continue;
    }
    if (k == n - 1 - (n - i) * 2) {
      ans.push_back(i);
      k = 0;
      sum += n - 1 - (n - i) * 2;
      for (int j = 1; j < i; ++j) ans.push_back(j);
      break;
    }
    for (int j = 1; j <= i; ++j) ans.push_back(j);
    int j = n - 1;
    while (k > 0) {
      if (ans[j] > j) {
        --k;
        ++sum;
      }
      swap(ans[j - 1], ans[j]);
      --j;
    }
    break;
  }
  if (ans.size() < n) {
    for (int i = 1; i <= n; ++i) {
      ans.push_back(i);
      if (ans.size() == n) break;
    }
  }
  cout << sum << endl;
  for (int i = 1; i <= n; ++i) cout << i << " ";
  cout << endl;
  for (LL i : ans) cout << i << " ";
  cout << endl;
  return 0;
}
