N, M, K = map(int, input().split()) op, *B = input().split() A = [int(input()) for _ in range(N)] B = list(map(int, B)) import numpy as np a=np.array(A) b=np.array(B) a=a%K b=b%K if op=='+': cnt=0 for i in range(n): c=a+b[i] cnt+=c.count(0) else: cnt=0 for i in range(n): c=a*b[i] cnt+=c.count(0) print(cnt)