n = int(input()) m1 = int(input()) a = list(map(int, input().split())) m2 = int(input()) b = list(map(int, input().split())) a1 = 0 A1 = [] for A in a: a1 += A A1.append(a1) b1 = 0 B1 = [] for B in b: b1 += B B1.append(b1) c = A1 + B1 c = set(c) print(n - len(c))