Jump
题号:NC15906
时间限制:C/C++/Rust/Pascal 1秒,其他语言2秒
空间限制:C/C++/Rust/Pascal 256 M,其他语言512 M
64bit IO Format: %lld

题目描述

The new version of Lianliankan is a game you love to play with. The rules of the game are as follows:
Give you n boxes, each with its own properties, two integers x, y. (1≤x,y≤10000)
You can only start from the box with property 1 then connect the next boxes which  has property 2 and so on.The properties of boxes you have chosen are increased.
Each box can only be selected once.When you choose the box,you can only use the one property of it.
In other words, you can only select a box with property 1 at first, then connect to a box with property 2, and then connect to a box with property 3.......
How many boxes can you connect ?(The more the better.ass we can)


输入描述:

The first line is one integer n(1≤n≤1000000)
Then n lines follow,each line contains two integers,which are the box‘s properties
Using fast I/O to avoid Time-Limit-Exceeded

输出描述:

Output the answer we want
示例1

输入

复制
4
1 2
2 4
2 3
2 5

输出

复制
4

说明

choose 1 of box 1 ,2 of box 4,3 of box 3,4 of box 2
示例2

输入

复制
4
1 2
1 2
2 3
1 2

输出

复制
3

说明

choose 1 of box 1 ,2 of box 2 and 3 of box 3