object Main extends App {
    val scan = new java.util.Scanner(System.in)
    val n, t = scan.next().toInt
    val as = (1 to n).toArray.map(_ => scan.next().toInt)
    var mins = as.scan(as(0))((n, m) => math.min(n,m)).drop(1)
    val cost = (0 until n).map(i => as(i) - mins(i)).zip(0 until n).sorted.reverse
    val min = cost.filter(_._1 == cost(0)._1).map(_._2)
    println(min.length)
}