#include <bits/stdc++.h>
using namespace std;
const long long INF = (1 << 30);
const long long NEGA = -INF * 10000;
int ans = 0;
int n, m;
int cnt = 0;
int LIS(vector<int> V) {
  int DP[200001] = {0};
  fill(DP, DP + V.size(), INF);
  for (int i = 0; i < V.size(); i++) {
    *lower_bound(DP, DP + V.size(), V[i]) = V[i];
  }
  return lower_bound(DP, DP + V.size(), INF) - DP;
}
vector<int> p;
int main() {
  int t;
  cin >> n >> t;
  int a[100001] = {0};
  for (int i = 0; i < n; i++) cin >> a[i];
  int maxv = -2000000;
  int minv = a[0];
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    maxv = max(maxv, a[i] - minv);
    minv = min(minv, a[i]);
  }
  int memo = maxv;
  maxv = -2000000;
  minv = a[0];
  int sm[100000] = {0};
  int p = 0;
  for (int i = 0; i < n; i++) {
    maxv = max(maxv, a[i] - minv);
    if (a[i] - minv == memo) cnt++;
    if (minv > a[i]) p = i;
    minv = min(minv, a[i]);
  }
  cout << cnt << endl;
}
