N = int(input()) M1 = int(input()) A = list(map(int, input().split())) M2 = int(input()) B = list(map(int, input().split())) stairs = [1]*(N+1) stairs[0] = 0 stairs[N] = 0 current = 0 for i in range(M1): current += A[i] stairs[current] = 0 current = N for i in range(M2): current -= B[i] stairs[current] = 0 #print(stairs) ans = sum(stairs) print(ans)