#include using namespace std; #include using namespace atcoder; using ll=long long; int main(){ int N; cin>>N; int sumA=0,sumB=0; vector A(N-1),B(N-1); for(int i=0;i>A[i]>>B[i]; sumA+=A[i],sumB+=B[i]; } int ans=0; for(int A1=0;A1<=sumB;A1++){ int B1=A1+sumA-sumB; sumA+=A1,sumB+=B1; if(A1<0||B1<0) continue; bool f=true; if(A1>sumB-B1) f=false; for(int i=0;isumB-B[i]) f=false; } if(f) ans++; sumA-=A1,sumB-=B1; } cout<