using System;
class HelloWorld
{

    static void Main() {

        int n = int.Parse(Console.ReadLine());
        var a = Console.ReadLine().Split();
        var b = Console.ReadLine().Split();
        var c = Console.ReadLine().Split();
        int[] X = new int[n];
        int[] Y = new int[n];
        int[] Z = new int[n];
        int i = 0;
        for(i=0;i<n;i++)
        {
            X[i] = int.Parse(a[i]);
            Y[i] = int.Parse(b[i]);
            Z[i] = int.Parse(c[i]);
        }
        int count = 0;
        int z = 0;
        for (i = 0; i < n; i++)
        {
            while ((X[i] != Y[z]) && z < n)
            {
                z++;
            }
            for (int l = 0; l < n; l++)
            {
                if (z + 1 == Z[l])
                {
                    count++;
                }
            }
        }


        Console.WriteLine(count);
    }
}