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

int main(){
    int pieces=1;
    int n;
    cin>>n;
    int a[n+1];
    int temp;
    for(int i=0;i<n; i++){
        cin>>temp;
        a[temp]=i;
    }
    int now, previous;
    cin>>temp;
    now=a[temp];
    for(int i=1; i<n; i++){
        cin>>temp;
        previous=now;
        now=a[temp];
        if(previous+1!=now){
            pieces++;
        }

    }
    cout<<pieces;
    return 0;
}
