from collections import * import heapq import bisect import itertools INF = float("inf") MOD = 998244353 mod = 998244353 N = int(input()) now = 0 dirty = [0] * (N + 1) M = int(input()) A = list(map(int, input().split())) for a in A: now += a dirty[now] = 1 now = N M = int(input()) A = list(map(int, input().split())) for a in A: now -= a dirty[now] = 1 print(dirty[1:].count(0))