#include <stdio.h>
int main() {
    int n;
    scanf("%d", &n);

    int x[n], y[n], z[n];
    for (int i = 0; i < n; i++) {
        scanf("%d", &x[i]);
    }
    for (int i = 0; i < n; i++) {
        scanf("%d", &y[i]);
    }
    for (int i = 0; i < n; i++) {
        scanf("%d", &z[i]);
    }

    int count = 0;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            if (x[i] == y[z[j]-1]) {
                count=count+1;
            }
        }
    }

    printf("%d\n", count);
    return 0;
}