using System;
using System.Collections.Generic;
using System.Linq;

namespace Kuvar
{
    class Program
    {
        static void Main()
        {
            int n = int.Parse(Console.ReadLine());
            int[] x = new int[n];
            int[] y = new int[n];
            int[] z = new int[n];

            string[] s = Console.ReadLine().Split();
            for (int i = 0; i < n; i++)
                x[i] = int.Parse(s[i]);
            s = Console.ReadLine().Split();
            for (int i = 0; i < n; i++)
                y[i] = int.Parse(s[i]);
            s = Console.ReadLine().Split();
            for (int i = 0; i < n; i++)
                z[i] = int.Parse(s[i]);

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

            Console.WriteLine(br);
        }
    }
}