##### Canadian Computing Olympiad: 2017 Day 2, Problem 2

Kevin is developing his professional network within a certain community. Unfortunately, he has not connected with anybody yet. But he has his eyes on potentially valuable connections, numbered from to . He is determined to connect with them all.

However, few people in this community are willing to friend an outsider. Each of the people Kevin wants to connect with has similar, but different criteria for determining who is an outsider and who isn't. Person is willing to friend Kevin if he either has at least connections within the community already, or if Kevin gives this person Internet Points.

Kevin likes his Internet Points very much, and so he doesn't want to give away too many. Now it is your job to help Kevin give away the least number of Internet Points while still making connections with each of the people.

#### Input Specification

The first line will contain the integer . Each of the next lines will contain integers and .

For 2 of the 25 available marks, for all .

For an additional 4 of the 25 available marks, .

For an additional 7 of the 25 available marks, .

#### Output Specification

Output one integer on a single line, the minimum number of Internet Points Kevin has to give away.

#### Sample Input 1

```
4
3 3
1 2
0 5
3 4
```

#### Sample Output 1

`3`

#### Explanation for Sample 1

Kevin can connect with person immediately, and with this connection made, he can also connect with person . He doesn't have enough connections to connect with person or person , so he gives Internet Points to person to acquire total connections which enables him to connect with person .

#### Sample Input 2

```
5
0 9
1 8
2 7
3 6
4 5
```

#### Sample Output 2

`0`

#### Explanation for Sample 2

It is possible that Kevin can connect with everyone without giving away any Internet Points.

#### Sample Input 3

```
3
0 6
2 7
3 8
```

#### Sample Output 3

`8`

#### Explanation for Sample 3

Kevin should connect with person immediately, then give Internet Points to person to connect with them, then connect with person .

## Comments