
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int maxMatchingPairs(vector<int> &a, vector<int> &b)
{
int n = a.size();
vector<int> position(n + 1, 0);
vector<int> shift_count(n, 0);
// Step 1: Create position array for b
for (int i = 0; i < n; ++i)
{
position[b[i]] = i;
}
// Step 2: Calculate shift counts
for (int i = 0; i < n; ++i)
{
int k = (position[a[i]] - i + n) % n; // Calculate the shift needed
shift_count[k]++;
}
// Step 3: Find the maximum shift count
return *max_element(shift_count.begin(), shift_count.end());
}
int main()
{
// Example
int n;
cin >> n;
vector<int> a(n);
vector<int> b(n);
for (auto &i : a)
cin >> i;
for (auto &i : b)
cin >> i;
cout << maxMatchingPairs(a, b) << endl;
return 0;
}
