|Contests||Virtual Contests||Problems||Submit||Runs Status||Rank List||Forum|
What is the minimum number of sticks after the connection?
The first line is a integer N (N ≤ 20000) indicating the number of given sticks. Each of the following N lines contains two integers p and q (0 ≤ p < q ≤ 108), denoting the two number carved on a stick.
Output the minimum number of sticks after the connection.