fun main(args:Array<String>?): Unit {
    val (n, m) = readLine()!!.trim().split(' ').map(String::toInt)
    val pictures = Array(n){
        val (s, v) = readLine()!!.trim().split(' ').map(String::toInt)
        Picture(s, v)
    }.sortedArrayDescending()
    val frames = IntArray(m){ readLine()!!.trim().toInt() }.sortedArrayDescending()
    var i = 0
    var count = 0
    for (frame in frames) {
        while(i < n && pictures[i].size > frame){
            ++i
        }
        if (i in pictures.indices) {
            ++count
            ++i
        }
    }
    println(count)
}
data class Picture(val size: Int, val value: Int): Comparable<Picture> {
    override fun compareTo(other: Picture): Int {
        return if (value == other.value) size.compareTo(other.size) else value.compareTo(other.value)
    }
}
