import std.stdio, std.string, std.conv;
import std.algorithm, std.array;
auto solve(string s_) {
    auto NT = s_.split.map!(to!int)();
    immutable N=NT[0], T=NT[1];
    auto A = readln.split.map!(to!int).array();
    int m=0,d=0,nl=0, nr=0, n=0, nm=0;
    foreach_reverse(v;A) {
        if(v>m) m=v,++n,nm=1;
        else if(v==m) ++n,++nm;
        else if(m-v>d) d=m-v,nl=1,nr=nm,n=nm;
        else if(m-v==d) ++nl,nr=n;
    }
    return min(nl,nr);

}
void main(){ for(string s; (s=readln.chomp()).length;) writeln(solve(s)); }