import collections N, M, K = [int(x) for x in input().split()] C = [x for x in input().split()] B = [int(x) for x in C[1:]] A = [int(input()) for _ in range(N)] B_K = [x % K for x in B] c_B_K = collections.Counter(B_K) ans = 0 for j in range(N): if C[0] == '+': ans += c_B_K[(K - A[j] % K) % K] else: q, r = divmod(K, (A[j] % K)) if r == 0: ans += c_B_K[q] else: ans += c_B_K[r + q + 1] ans += c_B_K[0] print(ans)