object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val n, t = sc.nextInt()
  val a = Array.fill(n)(sc.nextInt())
  val b = a.scanLeft(Int.MaxValue)((x, y) => x.min(y)).tail
  val c = a.zip(b).map{case (v, min) => v - min}
  val max = c.max
  println(c.count(_ == max))
}
