#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 5;
long long ans[maxn];
int main() {
  long long n, k, sum, cnt = 0;
  cin >> n >> k;
  sum = (1 + n) * n / 2;
  if (k < sum) {
    cout << "-1" << endl;
    return 0;
  }
  for (int i = 1; i <= n; i++) ans[i] = i;
  long long dif = k - sum, index1 = 1, index2 = n;
  while (dif && index1 < index2) {
    if (dif <= index2 - index1) {
      swap(ans[index1], ans[index1 + dif]);
      cnt += dif;
      dif = 0;
      break;
    }
    swap(ans[index1], ans[index2]);
    cnt += index2 - index1;
    dif -= index2 - index1;
    index1++;
    index2--;
  }
  cout << cnt + sum << endl;
  for (int i = 1; i <= n; i++) cout << i << " ";
  cout << endl;
  for (int i = 1; i <= n; i++) cout << ans[i] << " ";
  cout << endl;
  return 0;
}
