#include <bits/stdc++.h>
using namespace std;
long long N, M;
vector<pair<int, int> > res;
long long off;
int main() {
  cin >> N >> M;
  long long mval = 0;
  for (long long i = 1; i <= N; ++i) mval += max(N + 1 - i, i);
  if (mval < M) M = mval;
  long long m = N * (N + 1) / 2;
  M -= m;
  if (M < 0) {
    cout << -1;
    return 0;
  }
  cout << M + m << '\n';
  while (1) {
    long long ms = N - 1;
    if (M <= ms) {
      int dif = M;
      for (int i = 1; i <= N; ++i) {
        if (i == 1 || i == M + 1) continue;
        res.emplace_back(i + off, i + off);
      }
      res.emplace_back(M + 1 + off, 1 + off);
      if (M != 0) res.emplace_back(1 + off, M + 1 + off);
      sort(res.begin(), res.end());
      for (auto i : res) cout << i.first << ' ';
      cout << '\n';
      for (auto i : res) cout << i.second << ' ';
      return 0;
    } else {
      res.emplace_back(1 + off, N + off);
      res.emplace_back(N + off, 1 + off);
      ++off;
      N -= 2;
      M -= ms;
    }
  }
}
