using System;
class Takmicenje
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());

        int[] j = new int[n];
        string[] js = Console.ReadLine().Split(); 
        for (int i=0; i<n; i++)
        {
            j[i] = int.Parse(js[i]);
        }

        int[] r = new int[n];
        string[] rs = Console.ReadLine().Split();
        for (int i = 0; i < n; i++)
        {
            r[i] = int.Parse(js[i]);
        }

        int[] s = new int[n];
        string[] ss = Console.ReadLine().Split();
        for (int i = 0; i < n; i++)
        {
            s[i] = int.Parse(js[i]);
        }

        
        int z = 0;
        for (int i = 0; i < n; i++)
        {
            
            for (int o = 0; o < n; o++)
            {

                if (r[o] == j[i])
                {

                    for (int k = 0; k < n; k++)
                    {
                        if (s[k] == k + 1)
                        {
                            z++;
                        }
                        else
                            continue;
                    }
                }
                else
                    continue;
            }
        }
        Console.WriteLine(z);
    }
}