fun main(args: Array<String>) {
    val (n, t) = readLine()!!.split(' ').map { it.toInt() }
    val xs = readLine()!!.split(' ').map { it.toInt() }

    var cnt = 0
    var min = xs.first()
    var max = xs.first()
    var profit = 0

    for (a in xs.slice(1..xs.lastIndex).plus(-1)) {
        if (a < min) {
            val p = max - min

            if (p == profit) {
                cnt++
            } else if (p > profit) {
                cnt = 1
                profit = p
            }

            min = a
            max = a
        }
        max = Math.max(max, a)
    }

    println(cnt)
}
