import std; void main () { int N = readln.chomp.to!int; int M1 = readln.chomp.to!int; int[] A = readln.split.to!(int[]); int M2 = readln.chomp.to!int; int[] B = readln.split.to!(int[]); solve(N, M1, A, M2, B); } void solve (int N, int M1, int[] A, int M2, int[] B) { int[] arr = new int[](N+1); // 1 -> 汚れ | 0 -> 汚れてない int sum = 0; arr[sum] = 1; foreach (a; A) { sum += a; arr[sum] = 1; } foreach (b; B) { sum -= b; arr[sum] = 1; } int ans = 0; foreach (a; arr) { if (a == 0) { ans++; } } writeln(ans); }