#include <stdio.h>

#define MAX_N 100005

int n, x[MAX_N], y[MAX_N], z[MAX_N];

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

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

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