P2519 [HAOI2011] problem a

Description

An exam has $n$ participants, and multiple people may have the same score. The $i$-th person says: "There are $a_i$ people who scored higher than me, and $b_i$ people who scored lower than me." Find the minimum number of people who did not tell the truth.

Input Format

The first line contains an integer $n$, the number of participants. Lines $2$ to $(n + 1)$ each contain two space-separated integers. On the $(i + 1)$-th line, the two integers represent the number of people scoring higher than the $i$-th person $a_i$ and the number of people scoring lower than the $i$-th person $b_i$.

Output Format

Output a single integer, the minimum number of people who did not tell the truth.

Explanation/Hint

For $100\%$ of the testdata, it is guaranteed that $1 \leq n \leq 10^5$, $0 \leq a_i, b_i \leq n$. Translated by ChatGPT 5