#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<bool> d(N + 1, true);
  int M1;
  cin >> M1;
  int now = 0;
  while(M1--) {
    int A;
    cin >> A;
    d[now += A] = false;
  }
  int M2;
  cin >> M2;
  while(M2--) {
    int B;
    cin >> B;
    d[now -= B] = false;
  }
  cout << accumulate(d.begin(), d.end(), 0) << '\n';
  return 0;
}