#include<iostream>
using namespace std;
int arr1[100001];
int arr2[100001];
int temp[100001];
int main(){
    int n;
    cin>>n;
    int br=n;
    for(int i=0;i<n;i++){
        cin>>arr1[i];
    }
    for(int i=0;i<n;i++){
        cin>>arr2[i];
        temp[arr2[i]]=i;
    }
    arr1[n]=-1;
    arr2[n]=-2;
    for(int i=0;i<n;i++){
        if(arr1[i+1]==arr2[temp[arr1[i]]+1]){
            br--;
        }
    }
    cout<<br<<endl;
}

