Under construction

Still being built. Things may change

Testing

Interview

Time limit2sMemory limit1024 MB

Summary
Given n cards that each hold two different numbers from 1 to n+1, find the fewest cards to change so that one number appears on every card.
Level

Easy3 of 10

Topics
Array, Hash map, Implementation
Solved
No attempts yet

Statement

Sarah Connor needs to prove to Dr. Silberman, the chief physician of the clinic, that she is sane and capable of making sound judgments before she can see her son. As one of the tests, the doctor gives her the following problem.

Dr. Silberman: You broke my arm!

Sarah Connor: The human body has 215 bones. That was only one.

Terminator 2: Judgment Day

Dr. Silberman lays nn cards on the table. Each card has two natural numbers, and each number is between 1 and n+1n+1. No card has the same number written twice. No two cards have the same pair of numbers.

Sarah may pick some cards and change the numbers written on them. After her changes, there must be one number that is written on every card. The conditions above must still hold: every card is unique, and the two numbers on each card are different.

Sarah's task is to do this by changing as few cards as possible. Help her do it.

Input

The first line contains one integer nn (1≤n≤100 0001 \le n \le 100{\,}000), the number of cards on the table. The next nn lines each contain two different numbers from 1 to n+1n+1, the numbers written on the cards.

It is guaranteed that no two cards have the same pair of numbers, and no two cards have numbers that differ only in order.

Output

Print one line with the integer xx, the minimum number of cards Sarah Connor must change to pass the test.

Examples1

  1. Example 1

    Input
    4
    1 2
    2 3
    3 4
    4 5
    
    Expected output
    2