#include<bits/stdc++.h>
using namespace std;

int a[100005], nextt[100005];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int n;
    cin>>n;
    for(int i = 0; i < n; i++) {
        cin>>a[i];
        if(i != 0) nextt[a[i-1]] = a[i];
    }

    int ans = 1;
    for(int i = 0; i < n; i++) {
        int k, last;
        cin>>k;
        if(i != 0 && nextt[last] != k) ans++;
        last = k;
    }

    cout<<ans<<endl;


    return 0;
}
