#include using namespace std; using ll = long long; int main(){ ll N, M, A, S, ans=0; cin >> N; vector v(N+1); cin >> M; S = 0; for (int i=0; i> A; S += A; v[S] = 1; } cin >> M; S = 0; for (int i=0; i> A; S += A; v[S] = 1; } v[0] = 1; for (int i=0; i<=N; i++){ if (!v[i]) ans++; } cout << ans << endl; return 0; }