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

int main(){
ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
int n; cin >> n;
int x[n], y[n], z[n];
for ( int i = 0; i < n; i++ ){
    cin >> x[i];
}

for ( int j = 0; j < n; j++ ){
    cin >> y[j];
}
for ( int l = 0; l < n; l++ ){
    cin >> z[l];
}
ll br = 0;
if ( z[0] != z[1] ){
for ( int i = 0; i < n; i++ ){
    for ( int j = 0; j < n; j++ ){
        if ( x[i] == y[j] ){
            br++;
        }
    }
}
cout << br;
}
else{
    ll l = z[0]-1;
    for ( int i = 0; i < n; i++ ){
        if ( x[i] == y[l] ){
            br++;
        }
    }
    cout << br;
}
return 0;
}