
fun main(args: Array<String>) {
    readLine()!!
    val list: List<Int> = readLine()!!.split(" ").map { it.toInt() }.distinct()
    readLine()!!
    val list2: List<Int> = readLine()!!.split(" ").map { it.toInt() }.distinct()
    var match:Int = 0
    for (i in (0..list2.count()-1))
    {
        if (binarySearch(list,list2[i]) != -1)
        {
            match++
        }
    }
    println(match)
}
private fun binarySearch(A:List<Int>,key:Int):Int
{
    var left:Int = 0
    var right:Int= A.count()
    while (left<right)
    {
        var mid:Int = (left + right) / 2
        if (A[mid] == key)
        {
            return mid
        }
        else if (key < A[mid])
        {
            right = mid
        }
        else
        {
            left = mid+ 1
        }
    }
    return -1
}

