#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define PB push_back
#define LB lower_bound
#define UB upper_bound
#define PQ priority_queue
#define UM unordered_map
#define ALL(a) (a).begin(),(a).end()
typedef vector<ll> vi;
typedef vector<vector<ll>> vvi;
const ll INF = (1ll << 60);
typedef pair<ll,ll> pii;

int main(){
  ll N,V; cin>>N>>V;
  vvi v(4,vi(N));
  REP(i,4) REP(j,N) cin>>v[i][j];
  UM<ll,ll> ab,cd;
  REP(i,N) REP(j,N) ab[v[0][i]+v[1][j]]+=1;
  REP(i,N) REP(j,N) cd[v[2][i]+v[3][j]]+=1;
  ll ans=0;
  for(pii p:ab){
    ans+=p.second*cd[V-p.first];
  }
  cout<<ans<<endl;
}