import java.util.*; public class Main { public static void main (String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int sumA = 0; int sumB = 0; for (int i = 0; i < n - 1; i++) { sumA += sc.nextInt(); sumB += sc.nextInt(); } int count = Math.min(sumA, sumB) + 1; System.out.println(count); } }