#include int ri() { int n; scanf("%d", &n); return n; } int main() { int n = ri(); n--; int a_sum = 0, b_sum = 0; for (int i = 0; i < n; i++) a_sum += ri(), b_sum += ri(); std::cout << std::min(b_sum, a_sum) + 1 << std::endl; return 0; }