import sys N,M,K=map(int,input().split()) B=list(input().split()) A=[int(input()) for i in range(N)] ANS=0 from collections import Counter if B[0]=="+": B=list(map(int,B[1:])) A=Counter([a%K for a in A]) B=Counter([b%K for b in B]) for c in A: ANS+=A[c]*B[K-c] print(ANS) sys.exit() B=list(map(int,B[1:])) import math x=K xr=math.ceil(math.sqrt(x)) LIST=[] for i in range(1,xr+1): if x%i==0: LIST.append(i) LIST.append(x//i) L=sorted(set(LIST),reverse=True) SC=[0]*len(L) for i in range(len(L)): l=L[i] for b in B: if b%l==0: SC[i]+=1 for a in A: for i in range(len(L)): l=L[i] if a%l==0: ANS+=SC[len(L)-i-1] break print(ANS)