using System;

namespace ConsoleApp1
{
    internal class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int[] x = new int[n], y = new int[n], z = new int[n];
            string[] unos = Console.ReadLine().Split();
            for (int i = 0; i < n; i++)
                x[i] = int.Parse(unos[i]);
            unos = Console.ReadLine().Split();
            for (int i = 0; i < n; i++)
                y[i] = int.Parse(unos[i]);
            unos = Console.ReadLine().Split();
            for (int i = 0; i < n; i++)
                z[i] = int.Parse(unos[i]);
            int brNacina = 0;
            Array.Sort(x);Array.Sort(z);
            int br = 0;
            for(int i = 0; i < n; i++)
            {
                if(i!=0 && x[i] == x[i - 1]) { brNacina += br;continue; }
                br = 0;
                for (int l = 0, d = n - 1; l <= d; l++, d--)
                {

                    if (x[i] == y[l])
                    {
                        int iz = Array.BinarySearch(z, l + 1);
                        if (iz >= 0)
                        {
                            br++;
                            int k = 1;
                            while (iz-k >= 0 && z[iz] == z[iz - k])
                            {
                                br++;
                                k++;
                            }
                            while (iz+k <= n-1 && z[iz] == z[iz + k])
                            {
                                br++;
                                k++;
                            }
                        }
                    }
                    if (x[i] == y[d])
                    {
                        int iz = Array.BinarySearch(z, d + 1);
                        if (iz >= 0)
                        {
                            br++;
                            int k = 1;
                            while (iz-k >= 0 && z[iz] == z[iz - k])
                            {
                                br++;
                                k++;
                            }
                            while (iz + k <= n - 1 && z[iz] == z[iz + k])
                            {
                                br++;
                                k++;
                            }
                        }
                    }
                }
                brNacina += br;
            }
            Console.WriteLine(brNacina);
        }
    }
}