#include <bits/stdc++.h>

typedef long long ll;
typedef long double ld;

const int MAX_N = 1e5 + 42;
const int INF = 1e9;
const int mod = 1e9 + 7;

int a[MAX_N];
int b[MAX_N];
int pos[MAX_N];

int main () {

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

    int n;
    std::cin>>n;
    for( int i=0 ; i<n ; i++ ){
        std::cin>>a[i];
        pos[a[i]] = i;
    }

    for( int i=0 ; i<n ; i++ ) std::cin>>b[i];

    int nas = 0;
    for( int ind = 0; ind < n ; ind ++ ){
        int currPos = pos[b[ind]];
        while( currPos < n and a[currPos] == b[ind] ){
            currPos++;
            ind++;
        }
        nas ++;
    }

    std::cout<<nas+1<<"\n";

    return 0;
}
