```
public int fourSumCount(int[] A, int[] B, int[] C, int[] D) {
HashMap<Integer, Integer> hashMap = new HashMap<>();
for (int a : A) {
for (int b : B) {
hashMap.put(a + b, hashMap.getOrDefault(a + b, 0) + 1);
}
}
int result = 0;
for (int c : C) {
for (int d : D) {
result += hashMap.getOrDefault(-c - d, 0);
}
}
return result;
}
```

python

```
def fourSumCount(self, A, B, C, D):
AB = collections.Counter(a + b for a in A for b in B)
return sum(AB[-c - d] for c in C for d in D)
```