After the regional contest, all the ACMers are walking alone a very long avenue to the dining hall in groups. Groups can vary in size for kinds of reasons, which means, several players could walk together, forming a group.

As the leader of the volunteers, you want to know where each player is. So you call every player on the road, and get the reply like “Well, there are A_{i} players in front of our group, as well as B_{i} players are following us.” from the i^{th} player.

You may assume that only N players walk in their way, and you get N information, one from each player.

When you collected all the information, you found that you’re provided with wrong information. You would like to figure out, in the best situation, the number of people who provide correct information. By saying “the best situation” we mean as many people as possible are providing correct information.

As the leader of the volunteers, you want to know where each player is. So you call every player on the road, and get the reply like “Well, there are A

You may assume that only N players walk in their way, and you get N information, one from each player.

When you collected all the information, you found that you’re provided with wrong information. You would like to figure out, in the best situation, the number of people who provide correct information. By saying “the best situation” we mean as many people as possible are providing correct information.

There’re several test cases.

In each test case, the first line contains a single integer N (1 <= N <= 500) denoting the number of players along the avenue. The following N lines specify the players. Each of them contains two integers A_{i} and B_{i} (0 <= A_{i},B_{i} < N) separated by single spaces.

Please process until EOF (End Of File).

In each test case, the first line contains a single integer N (1 <= N <= 500) denoting the number of players along the avenue. The following N lines specify the players. Each of them contains two integers A

Please process until EOF (End Of File).

提交代码