using static System.Math;
using static System.Console;
using System.Collections.Generic;
using System.Linq;
using System;

class Program
{
    #region Reader
    static string ReadStr => Console.ReadLine();
    static string[] ReadStrs => Console.ReadLine().Split(' ');
    static int ReadInt => Convert.ToInt32(Console.ReadLine().Trim());
    static int[] ReadInts => Console.ReadLine().Trim().Split(' ').Select(s => Convert.ToInt32(s)).ToArray();
    static long ReadLong => Convert.ToInt64(Console.ReadLine().Trim());
    static long[] ReadLongs => Console.ReadLine().Trim().Split(' ').Select(s => Convert.ToInt64(s)).ToArray();
    static List<int[]> ReadPairs(int N)
    {
        List<int[]> ans = new List<int[]>();
        for (int i = 0; i < N; i++) { ans.Add(ReadInts); }
        return ans;
    }
    static List<long[]> ReadPairsLong(int N)
    {
        List<long[]> ans = new List<long[]>();
        for (int i = 0; i < N; i++) { ans.Add(ReadLongs); }
        return ans;
    }
    #endregion
    #region Method
    const int mod = 1000000007;
    public static int Mod(int a, int mod) { return a % mod >= 0 ? a % mod : a % mod + mod; }
    public static long Mod(long a, long mod = mod) { return a % mod >= 0 ? a % mod : a % mod + mod; }
    bool eq<T, U>() => typeof(T).Equals(typeof(U));
    T ct<T, U>(U a) => (T)Convert.ChangeType(a, typeof(T));
    T cv<T>(string s) => eq<T, int>() ? ct<T, int>(int.Parse(s))
                       : eq<T, long>() ? ct<T, long>(long.Parse(s))
                       : eq<T, double>() ? ct<T, double>(double.Parse(s))
                       : eq<T, char>() ? ct<T, char>(s[0])
                                         : ct<T, string>(s);
    void Multi<T>(out T a) => a = cv<T>(ReadStr);
    void Multi<T, U>(out (T,U) ans)
    {
        var ar = ReadStrs;
        ans =(cv<T>(ar[0]), cv<U>(ar[1]));
    }
    void Multi<T, U, V>(out (T,U,V) ans)
    {
        var ar = ReadStrs; 
        ans =(cv<T>(ar[0]), cv<U>(ar[1]),cv<V>(ar[2]));
    }
    void Multi<T,U>(out T a,out U b)
    {
        var ar = ReadStrs; 
        a = cv<T>(ar[0]);  b = cv<U>(ar[1]);
    }
    void Multi<T, U, V>(out T a,out U b,out V c)
    {
        var ar = ReadStrs;
        a = cv<T>(ar[0]);  b = cv<U>(ar[1]);  c = cv<V>(ar[2]);
    }
    #endregion

    public static Dictionary<int, int> PrimeFactors(int n)
    {
        int i = 2;
        int tmp = n;
        Dictionary<int, int> d = new Dictionary<int, int>();

        while (i * i <= n) //※1
        {
            if (tmp % i == 0)
            {
                tmp /= i;
                if (d.ContainsKey(i)) d[i]++;
                else d.Add(i, 1);
            }
            else
            {
                i++;
            }
        }
        if (tmp != 1)
        {
            if (d.ContainsKey(tmp)) d[tmp]++;
            else d.Add(tmp, 1);
        }
        return d;
    }

    static List<long> Divisor(long N)
    {
        List<long> ans = new List<long>();
        int max = (int)Math.Sqrt(N);
        for (int i = 1; i < max; i++)
        {
            if (N % i == 0)
            {
                ans.Add(i);
                ans.Add(N / i);
            }
        }

        if (N % max == 0)
        {
            if (N / max == max) ans.Add(max);
            else
            {
                ans.Add(max);
                ans.Add(N / max);
            }
        }
        return ans;
    }
    #region Mod
    public static long GetInv(long a, long mod = 1000000007)
    {
        return PowerMod(a, mod - 2, mod);
    }
    public static long Combination(long a, long b, long mod = 1000000007)
    {
        if (b < 0 || b > a) return 0;
        if (b > a / 2) b = a - b;
        long numerator = Factorial(a, mod);
        long denominator = (Factorial(b, mod) * Factorial(a - b, mod)) % mod;

        return (numerator * GetInv(denominator, mod)) % mod;
    }
    public static long Factorial(long n, long mod = 1000000007)
    {
        if (n == 0) return 1;
        if (n == 1) return 1;
        long ans = n;
        for (int i = 2; i < n; i++)
        {
            ans = (ans * i) % mod;
        }

        return ans;
    }
    private static long PowerMod(long a, long n, long mod = 1000000007)
    {
        if (n == 0) return 1;
        if (n == 1) return a;

        long p = PowerMod(a, n / 2, mod);
        if (n % 2 == 1) return ((p * p) % mod * a) % mod;
        else return (p * p) % mod;
    }
    #endregion

    static HashSet<int> Primes(int limit)
    {
        bool[] done = new bool[limit+1];

        var ans = new HashSet<int>();
        for (int i = 2; i <= limit; i++)
        {
            if (done[i]) continue;
            ans.Add(i);
            int index = i;
            while (index<=limit)
            {
                done[index] = true;
                index += i;
            }
        }
        return ans;
    }





    #region SegmentTree

    /// <summary>
    /// 行う演算は結合法則を満たす必要あり
    /// </summary>
    public class SegmentTree<T> where T : IComparable
    {
        /// <summary>
        /// 完全二分木
        /// </summary>
        public T[] Data { get; }

        /// <summary>
        /// 完全二分木に含まれる葉の数
        /// </summary>
        private int LeavesCount { get; }

        /// <summary>
        /// 数列(問題などで与えられる)の要素数
        /// </summary>
        public int Count { get; }

        /// <summary>
        /// 葉のうち使われなかったもの、そしてQueryで引数として取得した範囲がDataのインデックスの外である場合に使う
        /// </summary>
        public T Default { get; }


        public SegmentTree(T[] data, T def)
        {

            //初期値の設定
            Count = data.Length;
            Default = def;
            LeavesCount = (int)Pow(2, Ceiling(Log(data.Length, 2)));
            Data = new T[LeavesCount * 2];
            //

            //完全二分木の全要素を初期化
            for (int i = 0; i < LeavesCount * 2; i++)
            {
                Data[i] = def;
            }

            //dataを用いて必要な要素をすべて埋める
            for (int i = 0; i < data.Length; i++)
            {
                this[i] = data[i];
            }
        }

        public T this[int index]
        {
            get
            {
                //取得したい要素の位置は、実際は LeavesCount-1+index となる
                index = LeavesCount - 1 + index;

                return Data[index];
            }
            set
            {
                //偏光したい要素の位置は、実際は LeavesCount-1+index となる
                index = LeavesCount - 1 + index;

                //子を変更
                Data[index] = value;

                //親たちも含めて、要素を変更
                while (index > 0)
                {
                    //indexを親のインデックスに更新
                    index = GetParentIndex(index);

                    //要素を更新
                    Data[index] = DecideNewElementFromTwoChildren(index);
                }
            }
        }


        /// <summary>
        /// 唯一の親のインデックスを返す
        /// </summary>
        /// <param name="childIndex"></param>
        /// <returns></returns>
        private int GetParentIndex(int childIndex)
        {
            return (childIndex - 1) / 2;
        }

        /// <summary>
        /// 二つの子のインデックスを返す
        /// </summary>
        /// <param name="parentIndex"></param>
        /// <returns>小さいほうはl、大きいほうはr</returns>
        private (int l, int r) GetChildIndexes(int parentIndex)
        {
            return (2 * parentIndex + 1, 2 * parentIndex + 2);
        }

        /// <summary>
        /// 親の値を二つの子から決定する
        /// </summary>
        /// <param name="index"></param>
        /// <returns></returns>
        private T DecideNewElementFromTwoChildren(int index)
        {
            var children = GetChildIndexes(index);

            return Select(Data[children.l], Data[children.r]);
        }



        /// <summary>
        /// [a,b)の範囲で回答を探す
        /// </summary>
        /// <param name="a"></param>
        /// <param name="halfOpen_b"></param>
        /// <returns></returns>
        public T Query(int a, int halfOpen_b)
        {
            return _Query(a, halfOpen_b, 0, LeavesCount, 0);
        }

        private T _Query(int a, int b, int l, int r, int current)
        {
            //Φ
            if (a >= r || b <= l)
            {
                return Default;
            }
            //部分集合
            else if (a <= l && b >= r)
            {
                return Data[current];
            }
            //一部
            else
            {

                //(1) 範囲[l,r)を分割し、子lの回答と子rの回答を取得
                //(2) 二つの回答を比べて、適切(Selectメソッド)な方を返す


                //(1)
                var children = GetChildIndexes(current);
                T t1 = _Query(a, b, l, (l + r) / 2, children.l);
                T t2 = _Query(a, b, (l + r) / 2, r, children.r);

                //(2)
                return Select(t1, t2);
            }

        }





        /// <summary>
        /// カスタマイズするところ。二つの子の値から、親の値を決定する方法を定める。
        /// </summary>
        /// <param name="t1">子の値1</param>
        /// <param name="t2">子の値2</param>
        /// <returns></returns>
        private T Select(T t1, T t2)
        {
            return t1.CompareTo(t2) < 0 ? t2 : t1;
        }

    }

    #endregion


    static void Main()
    {
        int[] NM = ReadInts;
        int N = NM[0];
        int M = NM[1];

        int[] As = ReadInts;
        int[] max = new int[N - 1];
        max[N - 2] = As[N - 1];

        for (int i = N-3; i >=0; i--)
        {
            max[i] = Max(max[i + 1], As[i+1]);
        }

        int m = 0;
        int c = 0;
        for (int i = 0; i < N-1; i++)
        {
            int diff =  max[i]-As[i];
            if (m < diff)
            {
                m = diff;
                c = 1;
            }
            else if(m == diff)
            {
                c++;
            }
        }


        WriteLine(c);
    }



}



Measured memory_bytes: 38612