#include using namespace std; using ll = long long; int main() { cin.tie(0); ios::sync_with_stdio(false); int n; cin >> n; int as = 0, bs = 0; for (int i = 1; i < n; i++) { int a, b; cin >> a >> b; as += a; bs += b; } cout << bs - max(bs - as, 0) + 1 << endl; return 0; }