#define _USE_MATH_DEFINES #include using namespace std; //template #define rep(i,a,b) for(int i=(a);i<(b);i++) #define rrep(i,a,b) for(int i=(a);i>(b);i--) #define ALL(v) (v).begin(),(v).end() typedef long long int ll; typedef pair P; template inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } templatevoid Fill(A(&array)[N],const T &val){fill((T*)array, (T*)(array+N), val);} const int inf = 0x3fffffff; const ll INF = 0x3fffffffffffffff; //template end int main(){ int n; scanf("%d",&n); vector

a(n-1); int sum[2]={}; rep(i,0,n-1){ scanf("%d%d",&a[i].first,&a[i].second); sum[0]+=a[i].first; sum[1]+=a[i].second; } int ans=0; rep(i,0,sum[0]+1){ int rem=sum[1]+i-sum[0]; if(rem<0)continue; bool f=1; rep(i,0,n-1)if(a[i].second>sum[0]+rem-a[i].first)f=0; if(f)ans++; } printf("%d\n",ans); return 0; }