```
class Solution(object):
def fourSumCount(self, A, B, C, D):
ans, dic = 0, {}
for i in xrange(len(A)):
for j in xrange(len(B)):
tmp = A[i] + B[j]
if tmp in dic:
dic[tmp] += 1
else:
dic[tmp] = 1
for i in xrange(len(C)):
for j in xrange(len(D)):
tmp = -(C[i] + D[j])
if tmp in dic:
ans += dic[tmp]
return ans
```