The calendar
The scientists - archaeologists of the planet Olympia found two caves with signs of the presence of prehistoric tribes. Their attention was attracted by the n various words inscribed on the wall in each of the caves. Interestingly, these words in both caves turned out to be the same, but written out in different sequences. Scientists found that:
The written words are the names of the months of the year, which are listed in the order of occurrence of the relevant tribe.
The tribes' year is divided into n months of equal duration, and the days of the beginning of the months coincided.
However, scientists have not determined which month the year began for each of the tribes.
Write a program that, according to the sequence of the names of the months in both caves, will find the greatest number of months that could have the same name for both tribes, given that the year for the tribes could begin at different times. To simplify the analysis, the scientists assigned for each of the names of the month a positive integer from 1 to n.
Input
Consists of three lines. The first line contains positive integer n (2 ≤ n ≤ 10^5
) - the number of month names inscribed on the wall of each of the caves. The second line contains n different positive integers, each of which does not exceed n - the number of words in the order in which they are inscribed in the first cave. The third line also contains n different positive integers, each of which does not exceed n - the number of words in the order in which they are inscribed in the second cave.
Output
Print one number - the greatest number of months that could be called the same for both tribes.
Explanation to the first sample: If the year of the second tribe begins, for example, one month later than the first, then two months have the same names in the tribes (number 1 and 4):
No other combination matches a larger number of month names.
Explanation to the second sample: Regardless of when the year starts in the tribes, the same name will always have only one month.