#include using namespace std; using ll = long long; template istream& operator >> (istream& is, vector& vec) { for(T& x : vec) is >> x; return is; } template ostream& operator << (ostream& os, const vector& vec) { if(vec.empty()) return os; os << vec[0]; for(auto it = vec.begin(); ++it != vec.end(); ) os << ' ' << *it; return os; } int main(){ ios::sync_with_stdio(false); cin.tie(0); int n, m1, m2; cin >> n >> m1; vector a(m1); cin >> a >> m2; vector b(m2); cin >> b; vector used(n + 1); used[0] = true; int s = 0; for(int i = 0; i < m1; i++){ s += a[i]; used[s] = true; } s = n; for(int i = 0; i < m2; i++){ s -= b[i]; used[s] = true; } cout << n + 1 - count(used.begin(), used.end(), true) << '\n'; }