#include<iostream>
using namespace std;
int main ()
{
    int N;
    cin>>N;
    int a[N], b[N];
    for (int i=0; i<N; i++)
    {
        cin>>a[i];
    }
    for (int i=0; i<N; i++)
    {
        cin>>b[i];
    }
    int macks=1, br=1, n=2;
    for (int i=0; i<N; i++)
    {
        for (int q=0; q<N; q++)
        {
            while (a[i]==b[q])
            {
                if (i==0)
                {
                    n=n-1;
                }
                br++;
                i++;
                q++;
            }
            if (a[i]=='\0')
            {
                n=n-1;
            }
            if (br>macks)
            {
                macks=br;
            }
            br=1;
            n=2;
        }
    }
    cout<<N-macks+n;
    return 0;
}
