#!/usr/bin/env pypy3 import re from collections import deque from inspect import currentframe from pprint import pprint from string import ascii_lowercase as letter from string import ascii_uppercase from sys import setrecursionlimit, stderr, stdin from time import sleep as _time_sleep from typing import Dict, Generic, Iterable, Iterator, List, Optional, Set, Tuple, TypeVar, Union try: import pypyjit pypyjit.set_param('max_unroll_recursion=-1') except ModuleNotFoundError: ... INF: int = (1 << 62) - 1 MOD1000000007 = 10**9 + 7 MOD998244353 = 998244353 setrecursionlimit(500_000) # 5*10**5 readline = stdin.readline input = lambda: stdin.readline().rstrip('\r\n') def copy2d(a: list) -> list: return [[y for y in x] for x in a] def copy3d(a: list) -> list: return [[[z for z in y] for y in x] for x in a] def flattern2d(mat: list) -> list: return [x for a in mat for x in a] IS_DEVELOPMENT = None def debug(*a) -> None: global IS_DEVELOPMENT if IS_DEVELOPMENT is None: IS_DEVELOPMENT = __file__.endswith('/main.py') if not IS_DEVELOPMENT: return line_no = currentframe().f_back.f_lineno print(f"L{line_no}:", *a, file=stderr) def inputs(type_=int, one_word=False) -> list: in_ = input() if one_word: ins = list(in_) else: ins = in_.split() if isinstance(type_, Iterable): return [t(x) for t, x in zip(type_, ins)] else: return list(map(type_, ins)) def inputi() -> int: return int(readline()) yn = ['no', 'yes'] Yn = ['No', 'Yes'] YN = ['NO', 'YES'] # start coding n = inputi() inputi() A = inputs() inputi() B = inputs() # print(B) se = {0, n} now = 0 for x in A: now += x se.add(now) assert now == n for x in B: now -= x se.add(now) assert now == 0 print(n + 1 - len(se))