#include <bits/stdc++.h>
using namespace std;
const long long INF = 2e18;
const int INFi = 2e9;
const int maxN = 1e5 + 1;
const int P = 998244353;
const int md = 1e9 + 7;
double getTime() { return clock() / (double)CLOCKS_PER_SEC; };
void solve() {
  int n;
  long long k;
  cin >> n >> k;
  long long s = 1ll * n * (n + 1) / 2;
  if (s > k) {
    cout << -1;
    return;
  }
  vector<int> a(n, -1);
  int j = n - 1;
  for (int i = 0; i < n; ++i) {
    if (i >= j) break;
    if (s + j - i <= k) {
      s += j - i;
      a[i] = j;
      j--;
    }
  }
  cout << s << "\n";
  for (int i = 0; (i) < n; ++(i)) cout << i + 1 << " ";
  cout << "\n";
  j = 1;
  for (int i = 0; (i) < n; ++(i)) {
    if (a[i] == -1) {
      cout << j << " ";
      j++;
    } else {
      cout << a[i] + 1 << " ";
    }
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  int tests = 1;
  for (int _ = 0; (_) < tests; ++(_)) {
    solve();
  }
  return 0;
}
