fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val sList = readLine()!!.split(" ").map { it.toInt() }
    readLine()!!.toInt()
    val tList = readLine()!!.split(" ").map { it.toInt() }

    var total = 0

    for (number in tList) {
        if (binarySearch(number, n, sList)) total++
    }
    println(total)
}

fun binarySearch(target: Int, n: Int, list: List<Int>): Boolean {
    var left = 0
    var right = n
    while (left < right) {
        val mid = (left + right) / 2
        when {
            list[mid] == target -> return true
            target < list[mid] -> right = mid
            else -> left = mid + 1
        }
    }
    return false
}
