#include <bits/stdc++.h>
using namespace std;
int main() {
	int N, T;
	cin >> N >> T;
	vector<int> A(N);
	for (auto& x : A) cin >> x;
	auto B = A;
	for (int i = N-2; i >= 0; -- i) B[i] = max(B[i], B[i+1]);
	int C = 0;
	for (int i = 0; i < N; ++ i) C = max(C, B[i] - A[i]);
	int r = 0;
	for (int i = 0; i < N; ++ i) if (B[i] - A[i] == C) ++ r;
	cout << r << endl;
}
