import std.stdio, std.array, std.string, std.conv, std.algorithm; import std.typecons, std.range, std.random, std.math, std.container; import std.numeric, std.bigint, core.bitop, core.stdc.string; void main() { auto N = readln.chomp.to!int; auto A = iota(N-1).map!(_ => readln.split.map!(to!int).array).array; auto x = A.map!(a => a[0]).sum; auto y = A.map!(a => a[1]).sum; int ub = y; int lb = max(0, y - x); writeln(ub - lb + 1); }