eolymp
bolt
Try our new interface for solving problems
Problems

The calendar

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:

  1. The written words are the names of the months of the year, which are listed in the order of occurrence of the relevant tribe.

  2. 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 (2n105) - 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):

prb4972-ru

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.

Time limit 1 second
Memory limit 128 MiB
Input example #1
4
2 4 3 1
4 2 1 3
Output example #1
2
Input example #2
3
3 2 1
1 2 3
Output example #2
1
Author Daniil Mysak
Source 2013 XXVI All-Ukrainian Informatics Olympiad, Lugansk, March 17 - 21, Round 1