#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 9, mod = 1e9 + 7, INF = 0x3f3f3f3f;
int n;
long long m;
long long ans;
int a[N];
bool f[N];
int main() {
  cin >> n >> m;
  for (int i = 1; i <= n / 2; i++) {
    a[i] = i + (n + 1) / 2;
    ans += max(a[i], i);
  }
  for (int i = n / 2 + 1; i <= n; i++) {
    a[i] = i - n / 2;
    ans += max(i, a[i]);
  }
  long long num = (n + 1) / 2;
  for (int i = 1; i <= n / 2; i++) {
    if (ans > m) {
      a[i] -= min(ans - m, num);
      ans -= min(ans - m, num);
    }
    f[a[i]] = 1;
  }
  int cnt = 1;
  for (int i = n / 2 + 1; i <= n; i++) {
    while (f[cnt]) cnt++;
    a[i] = cnt;
    f[a[i]] = 1;
  }
  if (ans > m) {
    cout << -1;
    return 0;
  }
  cout << ans << '\n';
  for (int i = 1; i <= n; i++) {
    printf("%d ", i);
  }
  cout << '\n';
  for (int i = 1; i <= n; i++) {
    printf("%d ", a[i]);
  }
  return 0;
}
