#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, t, count = 0, max = 0;
  int a[100000] = {};
  cin >> n >> t;
  for (int i = 0; i < n; i++) cin >> a[i];
  int min = a[0];
  for (int i = 1; i < n; i++) {
    if (a[i] < min) min = a[i];
    if (a[i] - min > max) {
      max = a[i] - min;
      count = 0;
    } else if (a[i] - min == max)
      count++;
  }
  cout << count << endl;
  return 0;
}
