fun main(args: Array<String>) {
    readLine()
    val sArray = readLine()
        ?.split(" ".toRegex())
        ?.map(String::toInt)
        ?.toIntArray()
        ?: intArrayOf()
    readLine()
    val tArray = readLine()
        ?.split(" ".toRegex())
        ?.map(String::toInt)
        ?.toIntArray()
        ?: intArrayOf()
    println(tArray.filter {sArray.bSearch(it) != -1}.count())
}

fun IntArray.bSearch(key: Int, left: Int, right: Int): Int {
    val mid = (left + right) / 2
    if (left == mid) {
        if (this[mid] == key) {
            return mid
        } else {
            return -1
        }
    }
    if (this[mid] == key) {
        return mid
    } else if (this[mid] < key) {
        return this.bSearch(key, mid + 1, right)
    } else {
        return this.bSearch(key, left, mid)
    }
}

fun IntArray.bSearch(key: Int): Int {
    return this.bSearch(key, 0, this.size)
}
