405001: GYM101736 A Amazing Chef Masters

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

A. Amazing Chef Masterstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard output

The Amazing Chef Masters (ACM) have annual contests to determine the rankings of the members. Each chef has a skill level that could change over the years. Since each chef is a different individual, no two chefs will ever have the same skill level. The annual rankings are always based on the skill levels, so no ties will occur. More precisely, if chef A has a higher skill level than chef B, then chef A will have a better rank than chef B.

Usually the chefs would have a detailed record of the skill levels of the members each year, however, they were attacked by the Attacking Cactus Monsters (ACM)! These monstrous beings stole all of the records except the annual rankings.

Now the chefs want to regain some information about their skill levels. Given the rankings of two consecutive years, the chef masters would like to know the maximum possible number of chefs whose skill levels did not change.

Input

The first line of input contains a single integer n (1 ≤ n ≤ 105), the number of chefs in ACM.

The second line of input contains n distinct space-separated integers ai (1 ≤ ai ≤ n), describing the rank of the chefs in the first year. The aith chef has rank i in the first year.

The third line of input contains n distinct space-separated integers bi (1 ≤ bi ≤ n), describing the rank of the chefs in the second year. The bith chef has rank i in the second year.

Output

Print one integer that is the maximum possible number chefs whose skill levels did not change.

ExampleInput
4
2 3 1 4
3 2 1 4
Output
3
Note

This is the explanation for the sample. In the first year, chef 2 is ranked first, chef 3 is ranked second, chef 1 is ranked third, and chef 4 is ranked fourth. In the second year, chef 3 is ranked first, chef 2 is ranked second, chef 1 is ranked third, and chef 4 is ranked fourth. We can get the answer 3 by letting chefs 1, 3, and 4 have skill levels that remained unchanged, while chef 2's skill decreases.

加入题单

算法标签: