#include #include using namespace std; #define rep(i, n) for(int i=0; i #include int main() { int N; cin >> N; vector stare(N + 1, false); stare[0] = true; int M1; cin >> M1; vectorA(M1); rep(i, M1) { cin >> A[i]; } int M2; cin >> M2; vectorB(M2); rep(i, M2) { cin >> B[i]; } int now = 0; rep(i, M1) { now += A[i]; stare[now] = true; } rep(i, M2) { now -= B[i]; stare[now] = true; } int ans = 0; rep(i, N + 1) { if (!stare[i]) { ans++; } } cout << ans << endl; }