#include using namespace std; using ll = long long; using P = pair; #define rep(i, a, b) for(ll i = a; i < b; ++i) #define rrep(i, a, b) for(ll i = a; i >= b; --i) constexpr ll inf = 4e18; struct SetupIO { SetupIO() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(30); } } setup_io; int main(void) { int n; cin >> n; vector flag(n + 1); int m1; cin >> m1; vector a(m1); int cur = 0; flag[cur] = true; rep(i, 0, m1) { cin >> a[i]; cur += a[i]; flag[cur] = true; } assert(cur == n); int m2; cin >> m2; vector b(m2); rep(i, 0, m2) { cin >> b[i]; cur -= b[i]; flag[cur] = true; } assert(cur == 0); int ans = 0; rep(i, 0, n + 1) { if(!flag[i]) ans++; } cout << ans << '\n'; }