#include<bits/stdc++.h>
using namespace std;
int n, a[100003], b[100003];
int main(){

    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n;
    for(int i = 1; i <= n; i++)cin >> a[i];
    for(int i = 1; i <= n; i++)cin >> b[i];
    int ans = 0;
    for(int i = 1; i <= n; ){
        for(int j = 1; j <= n; j++){
            while(b[i] == a[j]){
                //cout << b[i] << " " << j << " " << i << endl;
                i++; j++;
            }
        }
        ans++;
    }
    cout << ans << endl;


    return 0;
}
