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

int ch1[100005], n, ans;

int main(){

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    cin >> n;

    int curr = 0, last = 0;
    for(int i = 0; i < n; i++){
        cin >> curr;
        ch1[last] = curr;
        last = curr;
    }

    int curr1 = 0, last1 = 0;
    for(int i = 0; i < n; i++){
        cin >> curr1;
        if(ch1[last1] != curr1) ans++;
        last1 = curr1;
    }

    cout << ans;

    return 0;
}
