#include <bits/stdc++.h>
using namespace std;

int main() {
    int n;
    long long v;
    cin >> n >> v;
    long long a[4][n];
    for (int i = 0; i < 4; ++i) for (int j = 0; j < n; ++j) cin >> a[i][j];
    long long b[n*n], c[n*n];
    for (int i = 0; i < n; ++i) for (int j = 0; j < n; ++j) b[i*n+j] = a[0][i] + a[1][j];
    for (int i = 0; i < n; ++i) for (int j = 0; j < n; ++j) c[i*n+j] = a[2][i] + a[3][j];
    sort(c, c+n*n);
    long long res = 0;
    for (int i = 0; i < n*n; ++i) res += upper_bound(c, c+n*n, v-b[i]) - lower_bound(c, c+n*n, v-b[i]);
    cout << res << endl;
}
