def solve(n, xs, ys): sx = sum(xs) sy = sum(ys) if sx < sy: sx, sy = sy, sx delta = sx - sy y_min = delta y_max = sx res = max(y_max - y_min + 1, 0) return res def main(): n = int(input()) xs = [] ys = [] for _ in range(n - 1): x, y = (int(z) for z in input().split()) xs.append(x) ys.append(y) res = solve(n, xs, ys) print(res) if __name__ == "__main__": main()