#include <bits/stdc++.h>
using namespace std;
const long long int mod = 1e9 + 7;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long int n, k;
  cin >> n >> k;
  vector<long long int> v(n);
  long long int stn = 0;
  for (long long int i = 0; i < n; i++) v[i] = i + 1, stn += i + 1;
  if (stn > k) {
    cout << -1;
    return 0;
  }
  for (long long int d = n - 1, i = 0; d && i < n / 2; d -= 2, i++)
    if (stn + d < k)
      swap(v[i], v[n - i - 1]), stn += d;
    else
      swap(v[i], v[i + k - stn]), stn = k;
  cout << stn << endl;
  for (long long int i = 0; i < n; i++) cout << i + 1 << " ";
  cout << endl;
  for (long long int i = 0; i < n; i++) cout << v[i] << " ";
  cout << endl;
  return 0;
}
