#include<iostream>
#include<iomanip>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;


int main(){
int n,pattern1,pattern2;
cin>>n;
int br=n;
int bar1[n];
int bar2[n];
for(int i=0;i<n;i++){
    cin>>bar1[i];
}
for(int i=0;i<n;i++){
    cin>>bar2[i];
}
for(int i=0;i<n-1;i++){
    pattern1=bar1[i];
    pattern2=bar1[i+1];
    for(int j=0;j<n-1;j++){
        if(bar2[j]==pattern1 && bar2[j+1]==pattern2){
            br--;
            break;
        }
    }

}
cout<<br;
return 0;
}

