#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 100;
int a[N];
map<int, vector<int> > mm;
int dp[N];
int cnt[N];
int main() {
  {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
  };
  int n, sum, i;
  cin >> n >> sum;
  for (i = 1; i <= n; i++) {
    cin >> a[i];
  }
  int curMin = a[1];
  int diff = 0;
  for (i = 2; i <= n; i++) {
    diff = max(diff, a[i] - curMin);
    curMin = min(curMin, a[i]);
  }
  curMin = a[1];
  int ans = 0;
  for (i = 2; i <= n; i++) {
    if (a[i] - curMin == diff) {
      ans++;
    }
    curMin = min(curMin, a[i]);
  }
  cout << ans << endl;
  return 0;
}
