/**
 * 線形探索
 */
fun main(args: Array<String>) {

    Main.init()

    Main.execute()
}

class Main {

    companion object {

        private lateinit var inputs: List<Int>

        private lateinit var searchLists: List<Int>

        fun init() {

            readLine()

            inputs = readLine()!!.split(" ").map { it.toInt() }

            readLine()

            searchLists = readLine()!!.split(" ").map { it.toInt() }

        }

        fun execute() {

            println(searchLists.count {
                isInclude(it)
            })
        }

        fun isInclude(searchString: Int): Boolean {

            /**
             * leftとrightは探索済みとして扱うので、存在しないindexを設定することがコツ
             */
            var leftIndex = -1
            var rightIndex = inputs.size

            var targetIndex = (leftIndex + rightIndex) / 2

            while (true) {

                val targetValue = inputs[targetIndex]
                if (targetValue == searchString) {
                    return true
                }

                if (targetValue < searchString) {
                    // 小さいので、leftを移動
                    leftIndex = targetIndex
                } else {
                    // 大きいので、rightを移動
                    rightIndex = targetIndex
                }

                if (rightIndex - leftIndex == 1) {
                    return false
                }

                targetIndex = (leftIndex + rightIndex) / 2
            }
        }
    }
}


