#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int n, t, diff = 0, soma = 0, menor = INT_MAX;
  cin >> n >> t;
  int arr[n];
  for (int i = 0; i < n; i++) cin >> arr[i];
  for (int i = 0; i < n; i++) {
    menor = min(menor, arr[i]);
    if (arr[i] - menor > diff) {
      soma = 1;
      diff = arr[i] - menor;
    } else if (arr[i] - menor == diff)
      soma++;
  }
  cout << soma << endl;
}
