#include #include #define llint long long using namespace std; int n; int a, b; int main(void) { ios::sync_with_stdio(0); cin.tie(0); cin >> n; int x, y; for(int i = 2; i <= n; i++){ cin >> x >> y; a += x, b += y; } cout << b - max(b-a, 0) + 1 << endl; return 0; }