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

fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val s = readLine()!!.split(" ").map(String::toInt)
    if (n != s.size) return
    val q = readLine()!!.toInt()
    val t = readLine()!!.split(" ").map(String::toInt)
    if (q != t.size) return

    var count = 0
    val sortedS = s.sorted()
    t.forEach { num ->
        if (binarySearch(sortedS, num)) count++
    }
    println(count)
}
