#include <bits/stdc++.h>

using namespace std;

int main()
{
    ios_base::sync_with_stdio(!"https://envs.sh/LW");
    cin.tie(0);

    int n;
    cin >> n;

    int s[int(1e5)];
    for (int i=0; i<n; ++i){
        cin >> s[i];
    }

    int p[int(1e5)+1]{0};
    int a;
    cin >> a;
    for (int i=1; i<n; ++i){
        int b;
        cin >> b;
        p[a] = b;
        a = b;
    }

    int ans=1;
    for (int i=0; i<n-1; ++i){
        if (p[s[i]] != s[i+1]){
            ans++;
        }
    }
    cout << ans << endl;

    return 0;
}
