import sys input = sys.stdin.readline def main(): N = int(input()) M1 = int(input()) A = list(map(int, input().split())) M2 = int(input()) B = list(map(int, input().split())) At = [0] * (M1 + 1) for i in range(M1): At[i+1] = At[i] + A[i] Bt = [N] * (M2 + 1) for i in range(M2): Bt[i+1] = Bt[i] - B[i] count = 0 for i in range(N+1): if (i not in At) and (i not in Bt): count += 1 print(count) if __name__ == '__main__': main()