fun main(args: Array<String>) {
    val (N, T) = readInputLine().split(" ").map { it.toInt() }
    val aList = readInputLine().split(" ").map { it.toInt() }
    val aListSorted = aList.mapIndexed { index, num -> Pair(index, num) }.sortedByDescending { it.second }.toMutableList()

    var maxDiff = 0
    var diffCnt = 0
    
    for ((i, num) in aList.withIndex()) {
        while (!aListSorted.isEmpty()) {
            val (maxIndex, maxNum) = aListSorted.first()
            if (maxIndex < i || maxNum < num) {
                aListSorted.removeAt(0)
            } else {
                break
            }
        }
        if (aListSorted.isEmpty()) {
            break
        }
        
        val diff = aListSorted.first().second - num
        if (diff > maxDiff) {
            maxDiff = diff
            diffCnt = 1
        } else if (diff == maxDiff) {
            diffCnt++
        }
    }
    
    println(diffCnt)
}

fun readInputLine(): String {
    return readLine()!!
}
