#include #define rep(i,n) for(int i=(0);i<(n);i++) using namespace std; typedef long long ll; int main(){ cin.tie(0); ios::sync_with_stdio(false); int n; cin >> n; ll asum = 0, bsum = 0; rep(i, n - 1){ ll a, b; cin >> a >> b; asum += a; bsum += b; } cout << min(asum, bsum) + 1 << endl; }