using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;

namespace Codeforces_CS
{
    class Class1
    {
        static void Main(string[] args)
        {
            new Class1().run();
        }

        void run()
        {
            InputReader cin = new InputReader(Console.OpenStandardInput());
            int n = cin.int32();
            int k = cin.int32();

            int[] arr = new int[n];
            for (int i = 0; i < n; i++)
                arr[i] = cin.int32();

            Array.Sort(arr);
            long[] pre = new long[n];
            pre[0] = arr[0];
            for (int i = 1; i < n; i++)
                pre[i] = arr[i] + pre[i - 1];

            //for (int i = 0; i < n; i++) Console.Write((i == 0 ? "" : " ") + arr[i]); Console.WriteLine();
            //for (int i = 0; i < n; i++) Console.Write((i == 0 ? "" : " ") + pre[i]); Console.WriteLine();

            int cnt = 1; int res = arr[0];
            for (int j = 1; j < n; j++)
            {
                int s = 0;
                int e = j;
                int a = 0;
                while(s <= e) {
                    int m = (s + e) >> 1;
                    long req = (j - m + 1) * arr[j];
                    long val = pre[j] - (m > 0 ? pre[m - 1] : 0);
                    long rem = req - val;
                    if (rem <= k)
                    {
                        a = m;
                        e = m - 1;
                    }
                    else
                    {
                        s = m + 1;
                    }
                }
                int occ = (j - a + 1);
                if (occ > cnt)
                {
                    cnt = occ;
                    res = arr[j];
                }

            }
            Console.WriteLine(cnt + " " + res);

        }

    }

    class InputReader
    {
        Stream inputStream;
        const int bufferSize = 1 << 16;
        int bytesRead;
        int currentBufferTop;
        byte[] buffer;

        public InputReader(Stream _inputStream)
        {
            this.inputStream = _inputStream;
            bytesRead = 0;
            currentBufferTop = 0;
            buffer = new byte[bufferSize];
        }

        public byte peekChar()
        {
            if (currentBufferTop < bytesRead)
            {
                return this.buffer[this.currentBufferTop];
            }
            else
            {
                if (!this.refill())
                {
                    throw new Exception("Error in reading input or reached EOF");
                }
                else
                {
                    return peekChar();
                }
            }
        }

        public byte readChar()
        {
            if (currentBufferTop < bytesRead)
            {
                return this.buffer[this.currentBufferTop++];
            }
            else
            {
                if (!this.refill())
                {
                    throw new Exception("Error in reading input or reached EOF");
                }
                else
                {
                    return readChar();
                }
            }
        }

        public bool refill()
        {
            currentBufferTop = 0;
            bytesRead = inputStream.Read(buffer, 0, bufferSize);
            return bytesRead > 0;
        }

        public int int32()
        {
            return (int) int64();
        }

        public long int64()
        {
            byte temp = peekChar();
            while (temp != '-' && (temp < '0' || temp > '9'))
            {
                readChar();
                temp = peekChar();
            }
            int sign = 1;
            if (temp == '-') sign = -1;
            if (temp == '-') readChar();
            long readValue = 0;
            temp = peekChar();
            while (temp >= '0' && temp <= '9')
            {
                readValue *= 10;
                readValue += (int)(temp - '0');
                readChar();
                try
                {
                    temp = peekChar();
                }
                catch (Exception e)
                {
                    break;
                }
            }
            return readValue * sign;
        }

        public string token()
        {
            byte temp = peekChar();
            while (isSpace(temp))
            {
                readChar();
                temp = peekChar();
            }

            StringBuilder sb = new StringBuilder();
            sb.Append(temp);
            try
            {
                temp = peekChar();
                while (!isSpace(temp))
                {
                    readChar();
                    temp = peekChar();
                }
            }
            catch (Exception e) { }
            return sb.ToString();
        }

        public string line()
        {
            StringBuilder sb = new StringBuilder();
            try
            {
                byte temp;
                do
                {
                    temp = peekChar();
                    sb.Append(temp);
                    readChar();
                } while (temp != '\n');
            }
            catch (Exception e) { }
            return sb.ToString();
        }

        private bool isSpace(byte t)
        {
            if (t == ' ') return true;
            if (t == '\t') return true;
            if (t == '\r') return true;
            if (t == '\n') return true;
            if (t == '\f') return true;
            return false;
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;

namespace Codeforces_CS
{
    class Class1
    {
        static void Main(string[] args)
        {
            new Class1().run();
        }

        void run()
        {
            InputReader cin = new InputReader(Console.OpenStandardInput());
            int n = cin.int32();
            int k = cin.int32();

            int[] arr = new int[n];
            for (int i = 0; i < n; i++)
                arr[i] = cin.int32();

            Array.Sort(arr);
            long[] pre = new long[n];
            pre[0] = arr[0];
            for (int i = 1; i < n; i++)
                pre[i] = arr[i] + pre[i - 1];

            //for (int i = 0; i < n; i++) Console.Write((i == 0 ? "" : " ") + arr[i]); Console.WriteLine();
            //for (int i = 0; i < n; i++) Console.Write((i == 0 ? "" : " ") + pre[i]); Console.WriteLine();

            int cnt = 1; int res = arr[0];
            for (int j = 1; j < n; j++)
            {
                int s = 0;
                int e = j;
                int a = 0;
                while(s <= e) {
                    int m = (s + e) >> 1;
                    long req = (j - m + 1) * arr[j];
                    long val = pre[j] - (m > 0 ? pre[m - 1] : 0);
                    long rem = req - val;
                    if (rem <= k)
                    {
                        a = m;
                        e = m - 1;
                    }
                    else
                    {
                        s = m + 1;
                    }
                }
                int occ = (j - a + 1);
                if (occ > cnt)
                {
                    cnt = occ;
                    res = arr[j];
                }

            }
            Console.WriteLine(cnt + " " + res);

        }

    }

    class InputReader
    {
        Stream inputStream;
        const int bufferSize = 1 << 16;
        int bytesRead;
        int currentBufferTop;
        byte[] buffer;

        public InputReader(Stream _inputStream)
        {
            this.inputStream = _inputStream;
            bytesRead = 0;
            currentBufferTop = 0;
            buffer = new byte[bufferSize];
        }

        public byte peekChar()
        {
            if (currentBufferTop < bytesRead)
            {
                return this.buffer[this.currentBufferTop];
            }
            else
            {
                if (!this.refill())
                {
                    throw new Exception("Error in reading input or reached EOF");
                }
                else
                {
                    return peekChar();
                }
            }
        }

        public byte readChar()
        {
            if (currentBufferTop < bytesRead)
            {
                return this.buffer[this.currentBufferTop++];
            }
            else
            {
                if (!this.refill())
                {
                    throw new Exception("Error in reading input or reached EOF");
                }
                else
                {
                    return readChar();
                }
            }
        }

        public bool refill()
        {
            currentBufferTop = 0;
            bytesRead = inputStream.Read(buffer, 0, bufferSize);
            return bytesRead > 0;
        }

        public int int32()
        {
            return (int) int64();
        }

        public long int64()
        {
            byte temp = peekChar();
            while (temp != '-' && (temp < '0' || temp > '9'))
            {
                readChar();
                temp = peekChar();
            }
            int sign = 1;
            if (temp == '-') sign = -1;
            long readValue = 0;
            temp = peekChar();
            while (temp >= '0' && temp <= '9')
            {
                readValue *= 10;
                readValue += (int)(temp - '0');
                readChar();
                try
                {
                    temp = peekChar();
                }
                catch (Exception e)
                {
                    break;
                }
            }
            return readValue * sign;
        }

        public string token()
        {
            byte temp = peekChar();
            while (isSpace(temp))
            {
                readChar();
                temp = peekChar();
            }

            StringBuilder sb = new StringBuilder();
            sb.Append(temp);
            try
            {
                temp = peekChar();
                while (!isSpace(temp))
                {
                    readChar();
                    temp = peekChar();
                }
            }
            catch (Exception e) { }
            return sb.ToString();
        }

        public string line()
        {
            StringBuilder sb = new StringBuilder();
            try
            {
                byte temp;
                do
                {
                    temp = peekChar();
                    sb.Append(temp);
                    readChar();
                } while (temp != '\n');
            }
            catch (Exception e) { }
            return sb.ToString();
        }

        private bool isSpace(byte t)
        {
            if (t == ' ') return true;
            if (t == '\t') return true;
            if (t == '\r') return true;
            if (t == '\n') return true;
            if (t == '\f') return true;
            return false;
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;

namespace Codeforces_CS
{
    class Class1
    {
        static void Main(string[] args)
        {
            new Class1().run();
        }

        void run()
        {
            InputReader cin = new InputReader(Console.OpenStandardInput());
            int n = cin.int32();
            int k = cin.int32();

            int[] arr = new int[n];
            for (int i = 0; i < n; i++)
                arr[i] = cin.int32();

            Array.Sort(arr);
            long[] pre = new long[n];
            pre[0] = arr[0];
            for (int i = 1; i < n; i++)
                pre[i] = arr[i] + pre[i - 1];

            for (int i = 0; i < n; i++) Console.Write((i == 0 ? "" : " ") + arr[i]); Console.WriteLine();
            for (int i = 0; i < n; i++) Console.Write((i == 0 ? "" : " ") + pre[i]); Console.WriteLine();

            int cnt = 1; int res = arr[0];
            for (int j = 1; j < n; j++)
            {
                int s = 0;
                int e = j;
                int a = 0;
                while(s <= e) {
                    int m = (s + e) >> 1;
                    long req = (j - m + 1) * arr[j];
                    long val = pre[j] - (m > 0 ? pre[m - 1] : 0);
                    long rem = req - val;
                    if (rem <= k)
                    {
                        a = m;
                        e = m - 1;
                    }
                    else
                    {
                        s = m + 1;
                    }
                }
                int occ = (j - a + 1);
                if (occ > cnt)
                {
                    cnt = occ;
                    res = arr[j];
                }

            }
            Console.WriteLine(cnt + " " + res);

        }

    }

    class InputReader
    {
        Stream inputStream;
        const int bufferSize = 1 << 16;
        int bytesRead;
        int currentBufferTop;
        byte[] buffer;

        public InputReader(Stream _inputStream)
        {
            this.inputStream = _inputStream;
            bytesRead = 0;
            currentBufferTop = 0;
            buffer = new byte[bufferSize];
        }

        public byte peekChar()
        {
            if (currentBufferTop < bytesRead)
            {
                return this.buffer[this.currentBufferTop];
            }
            else
            {
                if (!this.refill())
                {
                    throw new Exception("Error in reading input or reached EOF");
                }
                else
                {
                    return peekChar();
                }
            }
        }

        public byte readChar()
        {
            if (currentBufferTop < bytesRead)
            {
                return this.buffer[this.currentBufferTop++];
            }
            else
            {
                if (!this.refill())
                {
                    throw new Exception("Error in reading input or reached EOF");
                }
                else
                {
                    return readChar();
                }
            }
        }

        public bool refill()
        {
            currentBufferTop = 0;
            bytesRead = inputStream.Read(buffer, 0, bufferSize);
            return bytesRead > 0;
        }

        public int int32()
        {
            return (int) int64();
        }

        public long int64()
        {
            byte temp = peekChar();
            while (temp != '-' && (temp < '0' || temp > '9'))
            {
                readChar();
                temp = peekChar();
            }
            int sign = 1;
            if (temp == '-') sign = -1;
            if (temp == '-') readChar();
            long readValue = 0;
            temp = peekChar();
            while (temp >= '0' && temp <= '9')
            {
                readValue *= 10;
                readValue += (int)(temp - '0');
                readChar();
                try
                {
                    temp = peekChar();
                }
                catch (Exception e)
                {
                    break;
                }
            }
            return readValue * sign;
        }

        public string token()
        {
            byte temp = peekChar();
            while (isSpace(temp))
            {
                readChar();
                temp = peekChar();
            }

            StringBuilder sb = new StringBuilder();
            sb.Append(temp);
            try
            {
                temp = peekChar();
                while (!isSpace(temp))
                {
                    readChar();
                    temp = peekChar();
                }
            }
            catch (Exception e) { }
            return sb.ToString();
        }

        public string line()
        {
            StringBuilder sb = new StringBuilder();
            try
            {
                byte temp;
                do
                {
                    temp = peekChar();
                    sb.Append(temp);
                    readChar();
                } while (temp != '\n');
            }
            catch (Exception e) { }
            return sb.ToString();
        }

        private bool isSpace(byte t)
        {
            if (t == ' ') return true;
            if (t == '\t') return true;
            if (t == '\r') return true;
            if (t == '\n') return true;
            if (t == '\f') return true;
            return false;
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;

namespace Codeforces_CS
{
    class Class1
    {
        static void Main(string[] args)
        {
            new Class1().run();
        }

        void run()
        {
            InputReader cin = new InputReader(Console.OpenStandardInput());
            int n = cin.int32();
            long k = cin.int64();

            int[] arr = new int[n];
            for (int i = 0; i < n; i++)
                arr[i] = cin.int32();

            Array.Sort(arr);
            long[] pre = new long[n];
            pre[0] = arr[0];
            for (int i = 1; i < n; i++)
                pre[i] = arr[i] + pre[i - 1];

            //for (int i = 0; i < n; i++) Console.Write((i == 0 ? "" : " ") + arr[i]); Console.WriteLine();
            //for (int i = 0; i < n; i++) Console.Write((i == 0 ? "" : " ") + pre[i]); Console.WriteLine();

            int cnt = 1; int res = arr[0];
            for (int j = 1; j < n; j++)
            {
                int s = 0;
                int e = j;
                int a = j;
                while(s <= e) {
                    int m = (s + e) >> 1;
                    long req = (j - m + 1) * 1L * arr[j];
                    long val = pre[j] - (m > 0 ? pre[m - 1] : 0);
                    long rem = req - val;
                    if (rem <= k)
                    {
                        a = m;
                        e = m - 1;
                    }
                    else
                    {
                        s = m + 1;
                    }
                }
                int occ = (j - a + 1);
                if (occ > cnt)
                {
                    cnt = occ;
                    res = arr[j];
                }

            }
            Console.WriteLine(cnt + " " + res);

        }

    }

    class InputReader
    {
        Stream inputStream;
        const int bufferSize = 1 << 16;
        int bytesRead;
        int currentBufferTop;
        byte[] buffer;

        public InputReader(Stream _inputStream)
        {
            this.inputStream = _inputStream;
            bytesRead = 0;
            currentBufferTop = 0;
            buffer = new byte[bufferSize];
        }

        public byte peekChar()
        {
            if (currentBufferTop < bytesRead)
            {
                return this.buffer[this.currentBufferTop];
            }
            else
            {
                if (!this.refill())
                {
                    throw new Exception("Error in reading input or reached EOF");
                }
                else
                {
                    return peekChar();
                }
            }
        }

        public byte readChar()
        {
            if (currentBufferTop < bytesRead)
            {
                return this.buffer[this.currentBufferTop++];
            }
            else
            {
                if (!this.refill())
                {
                    throw new Exception("Error in reading input or reached EOF");
                }
                else
                {
                    return readChar();
                }
            }
        }

        public bool refill()
        {
            currentBufferTop = 0;
            bytesRead = inputStream.Read(buffer, 0, bufferSize);
            return bytesRead > 0;
        }

        public int int32()
        {
            return (int) int64();
        }

        public long int64()
        {
            byte temp = peekChar();
            while (temp != '-' && (temp < '0' || temp > '9'))
            {
                readChar();
                temp = peekChar();
            }
            int sign = 1;
            if (temp == '-') sign = -1;
            if (temp == '-') readChar();
            long readValue = 0;
            temp = peekChar();
            while (temp >= '0' && temp <= '9')
            {
                readValue *= 10;
                readValue += (int)(temp - '0');
                readChar();
                try
                {
                    temp = peekChar();
                }
                catch (Exception e)
                {
                    break;
                }
            }
            return readValue * sign;
        }

        public string token()
        {
            byte temp = peekChar();
            while (isSpace(temp))
            {
                readChar();
                temp = peekChar();
            }

            StringBuilder sb = new StringBuilder();
            sb.Append(temp);
            try
            {
                temp = peekChar();
                while (!isSpace(temp))
                {
                    readChar();
                    temp = peekChar();
                }
            }
            catch (Exception e) { }
            return sb.ToString();
        }

        public string line()
        {
            StringBuilder sb = new StringBuilder();
            try
            {
                byte temp;
                do
                {
                    temp = peekChar();
                    sb.Append(temp);
                    readChar();
                } while (temp != '\n');
            }
            catch (Exception e) { }
            return sb.ToString();
        }

        private bool isSpace(byte t)
        {
            if (t == ' ') return true;
            if (t == '\t') return true;
            if (t == '\r') return true;
            if (t == '\n') return true;
            if (t == '\f') return true;
            return false;
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;

namespace Codeforces_CS
{
    class Class1
    {
        static void Main(string[] args)
        {
            new Class1().run();
        }

        void run()
        {
            InputReader cin = new InputReader(Console.OpenStandardInput());
            int n = cin.int32();
            long k = cin.int64();

            int[] arr = new int[n];
            for (int i = 0; i < n; i++)
                arr[i] = cin.int32();

            Array.Sort(arr);
            long[] pre = new long[n];
            pre[0] = arr[0];
            for (int i = 1; i < n; i++)
                pre[i] = arr[i] + pre[i - 1];

            //for (int i = 0; i < n; i++) Console.Write((i == 0 ? "" : " ") + arr[i]); Console.WriteLine();
            //for (int i = 0; i < n; i++) Console.Write((i == 0 ? "" : " ") + pre[i]); Console.WriteLine();

            int cnt = 1; int res = arr[0];
            for (int j = 1; j < n; j++)
            {
                int s = 0;
                int e = j;
                int a = j;
                while(s <= e) {
                    int m = (s + e) >> 1;
                    long req = (j - m + 1) * arr[j];
                    long val = pre[j] - (m > 0 ? pre[m - 1] : 0);
                    long rem = req - val;
                    if (rem <= k)
                    {
                        a = m;
                        e = m - 1;
                    }
                    else
                    {
                        s = m + 1;
                    }
                }
                int occ = (j - a + 1);
                if (occ > cnt)
                {
                    cnt = occ;
                    res = arr[j];
                }

            }
            Console.WriteLine(cnt + " " + res);

        }

    }

    class InputReader
    {
        Stream inputStream;
        const int bufferSize = 1 << 16;
        int bytesRead;
        int currentBufferTop;
        byte[] buffer;

        public InputReader(Stream _inputStream)
        {
            this.inputStream = _inputStream;
            bytesRead = 0;
            currentBufferTop = 0;
            buffer = new byte[bufferSize];
        }

        public byte peekChar()
        {
            if (currentBufferTop < bytesRead)
            {
                return this.buffer[this.currentBufferTop];
            }
            else
            {
                if (!this.refill())
                {
                    throw new Exception("Error in reading input or reached EOF");
                }
                else
                {
                    return peekChar();
                }
            }
        }

        public byte readChar()
        {
            if (currentBufferTop < bytesRead)
            {
                return this.buffer[this.currentBufferTop++];
            }
            else
            {
                if (!this.refill())
                {
                    throw new Exception("Error in reading input or reached EOF");
                }
                else
                {
                    return readChar();
                }
            }
        }

        public bool refill()
        {
            currentBufferTop = 0;
            bytesRead = inputStream.Read(buffer, 0, bufferSize);
            return bytesRead > 0;
        }

        public int int32()
        {
            return (int) int64();
        }

        public long int64()
        {
            byte temp = peekChar();
            while (temp != '-' && (temp < '0' || temp > '9'))
            {
                readChar();
                temp = peekChar();
            }
            int sign = 1;
            if (temp == '-') sign = -1;
            if (temp == '-') readChar();
            long readValue = 0;
            temp = peekChar();
            while (temp >= '0' && temp <= '9')
            {
                readValue *= 10;
                readValue += (int)(temp - '0');
                readChar();
                try
                {
                    temp = peekChar();
                }
                catch (Exception e)
                {
                    break;
                }
            }
            return readValue * sign;
        }

        public string token()
        {
            byte temp = peekChar();
            while (isSpace(temp))
            {
                readChar();
                temp = peekChar();
            }

            StringBuilder sb = new StringBuilder();
            sb.Append(temp);
            try
            {
                temp = peekChar();
                while (!isSpace(temp))
                {
                    readChar();
                    temp = peekChar();
                }
            }
            catch (Exception e) { }
            return sb.ToString();
        }

        public string line()
        {
            StringBuilder sb = new StringBuilder();
            try
            {
                byte temp;
                do
                {
                    temp = peekChar();
                    sb.Append(temp);
                    readChar();
                } while (temp != '\n');
            }
            catch (Exception e) { }
            return sb.ToString();
        }

        private bool isSpace(byte t)
        {
            if (t == ' ') return true;
            if (t == '\t') return true;
            if (t == '\r') return true;
            if (t == '\n') return true;
            if (t == '\f') return true;
            return false;
        }
    }
}


#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i = (a) ; i<b ; i++)
#define Set(a,b) memset(a,b,sizeof(a))
#define mp make_pair
#define pb push_back
#define all(v) (v.begin(), v.end())
typedef long long LL;
using namespace std;

 int n,k;
 LL arr[100009];
 LL cum[100009];
int main()
{
    ios_base::sync_with_stdio(0);
   // freopen("input.in", "r", stdin);

    while(cin>>n>>k)
    {
        FOR(i,0,n)cin>>arr[i];
        sort(arr,arr+n);
        cum[0]=arr[0];
        FOR(i,1,n)
            cum[i] = cum[i-1] + arr[i];
        LL a=0,b=0;
        LL maxi=0;
        LL res = -1;
        while(b<n)
        {
            LL c = (a ? (cum[b]-cum[a-1]) : cum[b]);
            LL sup = arr[b]*(b-a+1);
            LL off = sup-c;
            if(off<=k)
            {
                if(b-a+1>maxi)
                    maxi = b-a+1, res=arr[b];
               b++;
            }
            else
            {
                ++a;
            }
        }
        cout <<maxi << " " <<  res <<endl;
    }

    return 0;
}


//============================================================================
// Name        : shit.cpp
// Author      : SaMer
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================
#include<bits/stdc++.h>
using namespace std;
#define mp make_pair
typedef long long ll;
int n,k;
vector<pair<int,int> >v;
int main(){
#ifndef ONLINE_JUDGE
	freopen("myfile.in","r",stdin);
#endif
	scanf("%d%d",&n,&k);
	vector<int>num(n);
	for(int i=0;i<n;++i) scanf("%d",&num[i]);
	sort(num.rbegin(),num.rend());
	int x=num[0],c=1;
	for(int i=1;i<n;++i)
		if(num[i]==x) c++;
		else v.push_back(mp(x,c)),c=1,x=num[i];
	v.push_back(mp(x,c));
	int dif,add=0,cur=0,mx=v[0].second,ans=0,tmp=v[cur].second,rem=k;
	for(int i=1;i<(int)v.size();++i){
		dif=v[cur].first-v[i].first,add=min(rem/dif,v[i].second);
		rem-=add*dif;
		tmp+=add;
		if(tmp>mx)mx=tmp,ans=cur;
		while(add<v[i].second){
			tmp-=(add+v[cur].second);
			rem+=add*dif;
			int u=v[cur].first-v[cur+1].first;
			rem+=u*tmp;
			cur++;
			dif=v[cur].first-v[i].first;add=min(rem/dif,v[i].second);
			rem-=add*dif;
			tmp+=add;
			if(tmp>mx)mx=tmp,ans=cur;
		}

	}
	printf("%d %d\n",mx,v[ans].first);
	return 0;
}


//============================================================================
// Name        : shit.cpp
// Author      : SaMer
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================
#include<bits/stdc++.h>
using namespace std;
#define mp make_pair
typedef long long ll;
int n,k;
vector<pair<int,int> >v;
int main(){
#ifndef ONLINE_JUDGE
    freopen("myfile.in","r",stdin);
#endif
    scanf("%d%d",&n,&k);
    vector<int>num(n);
    for(int i=0;i<n;++i) scanf("%d",&num[i]);
    sort(num.rbegin(),num.rend());
    int x=num[0],c=1;
    for(int i=1;i<n;++i)
        if(num[i]==x) c++;
        else v.push_back(mp(x,c)),c=1,x=num[i];
    v.push_back(mp(x,c));
    int dif,add=0,cur=0,mx=v[0].second,ans=0,tmp=v[cur].second,rem=k;
    for(int i=1;i<(int)v.size();++i){
        dif=v[cur].first-v[i].first,add=min(rem/dif,v[i].second);
        rem-=add*dif;
        tmp+=add;
        if(tmp>mx)mx=tmp,ans=cur;
        while(add<v[i].second){
            tmp-=(add+v[cur].second);
            rem+=add*dif;
            int u=v[cur].first-v[cur+1].first;
            rem+=u*tmp;
            cur++;
            if(cur==i) break;
            dif=v[cur].first-v[i].first;add=min(rem/dif,v[i].second);
            rem-=add*dif;
            tmp+=add;
            if(tmp>mx)mx=tmp,ans=cur;
        }

    }
    printf("%d %d\n",mx,v[ans].first);
    return 0;
}


//============================================================================
// Name        : shit.cpp
// Author      : SaMer
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================
#include<bits/stdc++.h>
using namespace std;
#define mp make_pair
typedef long long ll;
int n,k;
vector<pair<int,int> >v;
int main(){
#ifndef ONLINE_JUDGE
    freopen("myfile.in","r",stdin);
#endif
    scanf("%d%d",&n,&k);
    vector<int>num(n);
    for(int i=0;i<n;++i) scanf("%d",&num[i]);
    sort(num.rbegin(),num.rend());
    int x=num[0],c=1;
    for(int i=1;i<n;++i)
        if(num[i]==x) c++;
        else v.push_back(mp(x,c)),c=1,x=num[i];
    v.push_back(mp(x,c));
    int dif,add=0,cur=0,mx=v[0].second,ans=0,tmp=v[cur].second,rem=k;
    for(int i=1;i<(int)v.size();++i){
        dif=v[cur].first-v[i].first,add=min(rem/dif,v[i].second);
        rem-=add*dif;
        tmp+=add;
        if(tmp>=mx)mx=tmp,ans=cur;
        while(add<v[i].second){
            tmp-=(add+v[cur].second);
            rem+=add*dif;
            int u=v[cur].first-v[cur+1].first;
            rem+=u*tmp;
            cur++;
            if(cur==i){
                rem=k;
                tmp=v[i].second;
                if(tmp>=mx)mx=tmp,ans=cur;
                break;
            }
            dif=v[cur].first-v[i].first;add=min(rem/dif,v[i].second);
            rem-=add*dif;
            tmp+=add;
            if(tmp>=mx)mx=tmp,ans=cur;
        }

    }
    printf("%d %d\n",mx,v[ans].first);
    return 0;
}


#include<stdio.h>
#include<string.h>
#include<iostream>
#include<algorithm>
#include<math.h>
#include<string>
#include<map>
#include<vector>
using namespace std;

typedef __int64 LL;
#define clr(p,v) memset(p,v,sizeof(p));
const int maxn = 100010 ;
const int M = 1073741824;

LL n,m,l,k,cn;
LL f[maxn],g[maxn],cnt[maxn];
struct node
{
    LL v,cc;
}d[maxn];

LL Bin(LL right)
{
    LL l,r,mid,tt;
    l = 0;
    r = right;
    while(l<r)
    {
        mid = (l+r)>>1;
        tt = g[right]-g[mid-1]-cnt[mid-1]*(d[right].v-d[mid-1].v);
        if(tt <= k)
            r = mid;
        else
            l = mid+1;
    }
    return r;
}

int main()
{
   // freopen("k","r",stdin);
    scanf("%I64d%I64d",&n,&k);
    for(LL i=0;i<n;i++) scanf("%I64d",&f[i]);
    sort(f,f+n);
    cn = 0;
    d[0].v = f[0]; d[0].cc = 1;
    LL pr = f[0];
    for(LL i=1;i<n;i++)
    {
        if(pr==f[i])
        {
            d[cn].cc++;
        }
        else
        {
            d[++cn].v = f[i];
            d[cn].cc = 1;
            pr = f[i];
        }
    }
    //
    g[0] = 0;
    //int cc = d[0].cc;
    cnt[0] = d[0].cc;
    for(LL i=1;i<=cn;i++)
    {
        g[i] = cnt[i-1]*(d[i].v - d[i-1].v) + g[i-1];
        cnt[i] = cnt[i-1]+d[i].cc;
    }
    //
    LL ans = d[0].cc;
    LL res = d[0].v;
    for(LL i=1;i<=cn;i++)
    {
        if(ans < d[i].cc)
        {
            ans = d[i].cc;
            res = d[i].v;
        }
        LL tt = Bin(i),kk,num;
        kk = k;
        LL uu = g[i]-g[tt-1]-cnt[tt-1]*(d[i].v-d[tt-1].v);
        num = cnt[i]-cnt[tt-1];
        kk -= uu;
        if(tt)
            num += kk/(d[i].v-d[tt-1].v);
        if(num > ans)
        {
            ans = num;
            res = d[i].v;
        }
    }
    printf("%I64d %I64d\n",ans,res);
    return 0;
}


#include<stdio.h>
#include<string.h>
#include<iostream>
#include<algorithm>
#include<math.h>
#include<string>
#include<map>
#include<vector>
using namespace std;

typedef __int64 LL;
#define clr(p,v) memset(p,v,sizeof(p));
const int maxn = 100010 ;
const int M = 1073741824;

int n,m,l,k,cn;
int f[maxn],g[maxn],cnt[maxn];
struct node
{
    int v,cc;
}d[maxn];

int Bin(int right)
{
    int l,r,mid,tt;
    l = 0;
    r = right;
    while(l<r)
    {
        mid = (l+r)>>1;
        tt = g[right]-g[mid-1]-cnt[mid-1]*(d[right].v-d[mid-1].v);
        if(tt <= k)
            r = mid;
        else
            l = mid+1;
    }
    return r;
}

int main()
{
   // freopen("k","r",stdin);
    scanf("%d%d",&n,&k);
    for(int i=0;i<n;i++) scanf("%d",&f[i]);
    sort(f,f+n);
    cn = 0;
    d[0].v = f[0]; d[0].cc = 1;
    int pr = f[0];
    for(int i=1;i<n;i++)
    {
        if(pr==f[i])
        {
            d[cn].cc++;
        }
        else
        {
            d[++cn].v = f[i];
            d[cn].cc = 1;
            pr = f[i];
        }
    }
    //
    g[0] = 0;
    //int cc = d[0].cc;
    cnt[0] = d[0].cc;
    for(int i=1;i<=cn;i++)
    {
        g[i] = cnt[i-1]*(d[i].v - d[i-1].v) + g[i-1];
        cnt[i] = cnt[i-1]+d[i].cc;
    }
    //
    int ans = d[0].cc;
    int res = d[0].v;
    for(int i=1;i<=cn;i++)
    {
        if(ans < d[i].cc)
        {
            ans = d[i].cc;
            res = d[i].v;
        }
        int tt = Bin(i),kk,num;
        kk = k;
        int uu = g[i]-g[tt-1]-cnt[tt-1]*(d[i].v-d[tt-1].v);
        num = cnt[i]-cnt[tt-1];
        kk -= uu;
        if(tt)
            num += kk/(d[i].v-d[tt-1].v);
        if(num > ans)
        {
            ans = num;
            res = d[i].v;
        }
    }
    printf("%d %d\n",ans,res);
    return 0;
}


#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cassert>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <complex>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <functional>
#include <iterator>

using namespace std;

#define dump(n) cout<<"# "<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;
typedef pair<int,int> pii;

const int INFTY=1<<29;
const double EPS=1e-9;

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& a){
	os<<'[';
	rep(i,a.size()) os<<(i?" ":"")<<a[i];
	return os<<']';
}

int Need(int x)
{
	x--;
	rep(i,5) x|=x>>(1<<i);
	return x+1;
}

template<int I,const int&(*F)(const int&,const int&)>
struct SegmentTree{
	int size;
	vi data;
	SegmentTree(int s):size(Need(s)),data(size*2,I){}
	SegmentTree(const vi& a):size(Need(a.size())),data(size*2,I){
		copy(all(a),data.begin()+size);
		for(int i=size;--i;)
			data[i]=F(data[i*2],data[i*2+1]);
	}
	int Get(int i){
		return data[size+i];
	}
	void Update(int i,int x){
		data[size+i]=x;
		for(i=(i+size)/2;i;i/=2)
			data[i]=F(data[i*2],data[i*2+1]);
	}
	int Query(int a,int b,int i,int l,int r){
		if(b<=l || r<=a) return I;
		if(a<=l && r<=b) return data[i];
		return F(Query(a,b,i*2,l,(l+r)/2),Query(a,b,i*2+1,(l+r)/2,r));
	}
	int Query(int a,int b){
		return Query(a,b,1,0,size);
	}
};

int main()
{
	for(int n,k;cin>>n>>k;){
		vi a(n);
		rep(i,n) cin>>a[i];
		sort(all(a));

		vector<ll> sum(n+1);
		rep(i,n) sum[i+1]=sum[i]+a[i];

		SegmentTree<INT_MIN,max<int>> stmax(a);

		int resn=-1,resc=-1;
		rep(i,n){
			int lo=0,hi=i;
			while(lo<hi){
				int m=(lo+hi)/2;
				ll mx=stmax.Query(m,i+1);
				ll sm=sum[i+1]-sum[m];
				if(mx*(i+1-m)-sm<=k)
					hi=m;
				else
					lo=m+1;
			}
			if(resc<i+1-lo){
				resc=i+1-lo;
				resn=a[i];
			}
		}
		cout<<resc<<' '<<resn<<endl;
	}

	return 0;
}


#include<iostream>
#include<fstream>
#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<algorithm>
#include<iomanip>
#include<bitset>
#include<stdio.h>
#include<stdlib.h>
#include<cmath>
#include<functional>
#define ll long long
#define ull unsigned long long
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep2(i,a,b) for(int i=(int)a;i<(int)b;i++)
#define vll vector<long long>
#define vi vector<int>
#define pb(i) push_back( i )
#define ii pair<int,int>
#define vii vector <pair<int,int> >
#define mp(i,j) ( make_pair ( i , j ) )
#define dri(x) scanf("%d",&(x))
#define drii(x,y) scanf("d",&(x),&(y))
#define drl(x) scanf("%I64d",&(x))
#define drll(x,y) scanf("I64d",&(x),&(y))
#define CLR(a) memset((a), 0 ,sizeof(a))
using namespace std;
const ll oo=2e9,mod=1000000007;
ll n , k ;
ll a[100003] , s[100003];

   bool ok(ll mid , int i){
      if( mid - i > 1 ) return 0 ;
        return  ( mid * a[ i ] ) - ( s[ i ] - s[ i - mid ] ) <= k ;
   }

   ll calc( int i ) {
    ll lo = 1 , hi = i + 1  ;
        while( lo <= hi ){
                if( lo == hi - 1 ) return ok( hi , i ) ? hi : lo ;
                 if(lo == hi) return lo ;

                     ll mid = (hi + lo) / 2 ;

                             if( ok( mid  , i ) ) lo = mid ;
                                else hi = mid - 1 ;
             }

        }

int main(){
cin.sync_with_stdio(false);
cin>>n>>k;
n++;
rep2( i , 1 , n ){
    cin>>a[ i ];
    }
sort( a + 1 , a + n ) ;
a[0]=s[0]=0;
s[ 1 ] = a[ 1 ] ;
    rep2( i , 2 , n ){
       s[ i ] = s[i - 1] + a[ i ] ;
    }

ll MAX = -1 , NUM = -1 ;
   for( int i = n - 1 ; i>0 ; i--){
       ll res = calc( i );
       if(res > MAX){
          MAX = res ; NUM = a[ i ] ;
       }
       if(res == MAX){
         NUM = min ( NUM , a[ i ] ) ;
       }
   }
cout<<MAX<<" "<<NUM<<endl;
return 0;
}


#include<iostream>
#include<fstream>
#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<algorithm>
#include<iomanip>
#include<bitset>
#include<stdio.h>
#include<stdlib.h>
#include<cmath>
#include<functional>
#define ll long long
#define ull unsigned long long
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep2(i,a,b) for(int i=(int)a;i<(int)b;i++)
#define vll vector<long long>
#define vi vector<int>
#define pb(i) push_back( i )
#define ii pair<int,int>
#define vii vector <pair<int,int> >
#define mp(i,j) ( make_pair ( i , j ) )
#define dri(x) scanf("%d",&(x))
#define drii(x,y) scanf("d",&(x),&(y))
#define drl(x) scanf("%I64d",&(x))
#define drll(x,y) scanf("I64d",&(x),&(y))
#define CLR(a) memset((a), 0 ,sizeof(a))
using namespace std;
const ll oo=2e9,mod=1000000007;
ll n , k ;
ll a[100003] , s[100003];

   bool ok(ll mid , int i){
      if( mid - i > 0 ) return 0 ;
        return  ( mid * a[ i ] ) - ( s[ i ] - s[ i - mid ] ) <= k ;
   }

   ll calc( int i ) {
    ll lo = 1 , hi = i + 1  ;
        while( lo <= hi ){
                if( lo == hi - 1 ) return ok( hi , i ) ? hi : lo ;
                 if(lo == hi) return lo ;

                     ll mid = (hi + lo) / 2 ;

                             if( ok( mid  , i ) ) lo = mid ;
                                else hi = mid - 1 ;
             }

        }

int main(){
cin.sync_with_stdio(false);
cin>>n>>k;
n++;
rep2( i , 1 , n ){
    cin>>a[ i ];
    }
sort( a + 1 , a + n ) ;
a[0]=s[0]=0;
s[ 1 ] = a[ 1 ] ;
    rep2( i , 2 , n ){
       s[ i ] = s[i - 1] + a[ i ] ;
    }

ll MAX = -1 , NUM = -1 ;
   for( int i = n - 1 ; i>0 ; i--){
       ll res = calc( i );
       if(res > MAX){
          MAX = res ; NUM = a[ i ] ;
       }
       if(res == MAX){
         NUM = min ( NUM , a[ i ] ) ;
       }
   }
cout<<MAX<<" "<<NUM<<endl;
return 0;
}


/*
Author :: MD. Musfiqur Rahman Sanim
Aust cse 28th Batch
ID:11.02.04.097
*/

//{ Template
using namespace std;
//{ headers
#include<bits/stdc++.h>
//}
//{ Loops
#define forab(i,a,b) for (__typeof(b) i = (a); i <= (b); ++i)
#define rep(i,n) forab (i, 0, (n) - 1)
#define For(i,n) forab (i, 1, n)
#define rofba(i,a,b) for (__typeof(b) i = (b); i >= (a); --i)
#define per(i,n) rofba (i, 0, (n) - 1)
#define rof(i,n) rofba (i, 1, n)
#define forstl(i,s) for (__typeof ((s).end ()) i = (s).begin (); i != (s).end (); ++i)
//}
//{ Floating-points
#define EPS 1e-7
#define abs(x) (((x) < 0) ? - (x) : (x))
#define zero(x) (abs (x) < EPS)
#define equal(a,b) (zero ((a) - (b)))
#define PI 2*acos (0.0)
//}
typedef long long int64;
typedef unsigned long long int64u;
#define memo(a,v) memset(a,v,sizeof(a))
#define all(a) a.begin(),a.end()
#define db double
#define pb push_back
#define eb emplace_back
#define pii pair<int ,int >
#define NL puts("")
#define ff first
#define ss second
//{
//Intput_Output
#define gc getchar
#define II ({ int a; read(a); a;})
#define IL ({ int64 a; read(a);  a;})
#define ID ({ db a; scanf("%lf",&a);  a;})
#define IC ({ char a; scanf("%c",&a);  a;})
#define IS ({ string a; cin >> a;  a;})
#define OC printf("Case %d:",cs);
//}
//}
#define _stl(x) {__stl_print__(x);}
#define __(args...) {dbg,args; cerr<<endl;}
template<class T>inline bool read(T &x){int c=gc();int sgn=1;while(~c&&c<'0'|c>'9'){if(c=='-')sgn=-1;c=gc();}for(x=0;~c&&'0'<=c&&c<='9';c=gc())x=x*10+c-'0';x*=sgn;return ~c;}
struct debugger{template<typename T> debugger& operator , (const T& v){cerr<<v<<"    "; return *this; }}dbg;
template <class T> void __stl_print__ (T &x) { // for all STL containers
    cerr << "["; forstl (i, x) cerr << (i != x.begin () ? ", " : "") << *i; cerr << "]" << endl;
}
template <class T, class U> inline T max (T &a, U &b)
{
    return a > b ? a : b;
}
template <class T, class U> inline T min (T &a, U &b)
{
    return a < b ? a : b;
}
template <class T, class U> inline T swap (T &a, U &b)
{
    T tmp = a;
    a = b;
    b = tmp;
}
//int dx[]={1,0,-1,0};int dy[]={0,1,0,-1}; //4 Direction
//int dx[]={1,1,0,-1,-1,-1,0,1};int dy[]={0,1,1,1,0,-1,-1,-1};//8 Direction
//int dx[]={2,1,-1,-2,-2,-1,1,2};int dy[]={1,2,2,1,-1,-2,-2,-1};//Knight Direction
//int dx[6]={2,1,-1,-2,-1,1};int dy[6]={0,1,1,0,-1,-1}; //Hexagonal Direction

const int64 INF = (1ll)<<50;
const int mx = 1e5 + 7;
const int mod = 1000000007 ;
const db pi = PI;
int EQ(double d) {
    if ( fabs(d) < EPS ) return 0;
    return d > EPS ? 1 : -1 ;
}
int64 arr[mx];
int main() {
#ifdef Sanim
	//geting WA check int64 & int64u
    freopen ("in.txt", "r", stdin);
    // freopen ("output.txt", "w", stdout);
#endif
    int64 n = IL,k = IL;
    For(i,n) arr[i] = IL;
    sort(arr+1,arr+n+1);
    For(i,n)arr[i] += arr[i-1];
    int64 a = 0,id;
    For(i,n){
        int64 low = 1,high = i,ans = i;
        int64 num = arr[i] - arr[i-1];
        while(low<=high){
            int64 mid = (low+high)>>1;
            int64 tmp1 = arr[i] - arr[mid-1];
            int64 tmp2 = (i - mid + 1)*num;
            int64 tmp = tmp2 - tmp1;

            if(tmp<=k){
                high = mid - 1;
                ans = mid;
            }else low = mid + 1;
        }

        ans = i - ans + 1;
        if(a<ans){
            a = ans;
            id = num;
        }
    }
    cout << a << ' ' << id << endl;
}


/*
Author :: MD. Musfiqur Rahman Sanim
Aust cse 28th Batch
ID:11.02.04.097
*/

//{ Template
using namespace std;
//{ headers
#include<bits/stdc++.h>
//}
//{ Loops
#define forab(i,a,b) for (__typeof(b) i = (a); i <= (b); ++i)
#define rep(i,n) forab (i, 0, (n) - 1)
#define For(i,n) forab (i, 1, n)
#define rofba(i,a,b) for (__typeof(b) i = (b); i >= (a); --i)
#define per(i,n) rofba (i, 0, (n) - 1)
#define rof(i,n) rofba (i, 1, n)
#define forstl(i,s) for (__typeof ((s).end ()) i = (s).begin (); i != (s).end (); ++i)
//}
//{ Floating-points
#define EPS 1e-7
#define abs(x) (((x) < 0) ? - (x) : (x))
#define zero(x) (abs (x) < EPS)
#define equal(a,b) (zero ((a) - (b)))
#define PI 2*acos (0.0)
//}
typedef long long int64;
typedef unsigned long long int64u;
#define memo(a,v) memset(a,v,sizeof(a))
#define all(a) a.begin(),a.end()
#define db double
#define pb push_back
#define eb emplace_back
#define pii pair<int ,int >
#define NL puts("")
#define ff first
#define ss second
//{
//Intput_Output
#define gc getchar
#define II ({ int a; read(a); a;})
#define IL ({ int64 a; read(a);  a;})
#define ID ({ db a; scanf("%lf",&a);  a;})
#define IC ({ char a; scanf("%c",&a);  a;})
#define IS ({ string a; cin >> a;  a;})
#define OC printf("Case %d:",cs);
//}
//}
#define _stl(x) {__stl_print__(x);}
#define __(args...) {dbg,args; cerr<<endl;}
template<class T>inline bool read(T &x){int c=gc();int sgn=1;while(~c&&c<'0'|c>'9'){if(c=='-')sgn=-1;c=gc();}for(x=0;~c&&'0'<=c&&c<='9';c=gc())x=x*10+c-'0';x*=sgn;return ~c;}
struct debugger{template<typename T> debugger& operator , (const T& v){cerr<<v<<"    "; return *this; }}dbg;
template <class T> void __stl_print__ (T &x) { // for all STL containers
    cerr << "["; forstl (i, x) cerr << (i != x.begin () ? ", " : "") << *i; cerr << "]" << endl;
}
template <class T, class U> inline T max (T &a, U &b)
{
    return a > b ? a : b;
}
template <class T, class U> inline T min (T &a, U &b)
{
    return a < b ? a : b;
}
template <class T, class U> inline T swap (T &a, U &b)
{
    T tmp = a;
    a = b;
    b = tmp;
}
//int dx[]={1,0,-1,0};int dy[]={0,1,0,-1}; //4 Direction
//int dx[]={1,1,0,-1,-1,-1,0,1};int dy[]={0,1,1,1,0,-1,-1,-1};//8 Direction
//int dx[]={2,1,-1,-2,-2,-1,1,2};int dy[]={1,2,2,1,-1,-2,-2,-1};//Knight Direction
//int dx[6]={2,1,-1,-2,-1,1};int dy[6]={0,1,1,0,-1,-1}; //Hexagonal Direction

const int64 INF = (1ll)<<50;
const int mx = 1e5 + 7;
const int mod = 1000000007 ;
const db pi = PI;
int EQ(double d) {
    if ( fabs(d) < EPS ) return 0;
    return d > EPS ? 1 : -1 ;
}
int64 arr[mx];
int main() {
#ifdef Sanim
	//geting WA check int64 & int64u
    freopen ("in.txt", "r", stdin);
    // freopen ("output.txt", "w", stdout);
#endif
    int64 n = IL,k = IL;
    For(i,n) arr[i] = IL;
    sort(arr+1,arr+n+1);
    For(i,n)arr[i] += arr[i-1];
    int64 a = 0,id;
    For(i,n){
        int64 low = 1,high = i,ans = i;
        int64 num = arr[i] - arr[i-1];
        while(low<=high){
            int64 mid = (low+high)>>1;
            int64 tmp1 = arr[i] - arr[mid-1];
            int64 tmp2 = (i - mid + 1)*num;
            int64 tmp = tmp2 - tmp1;

            if(tmp<=k){
                high = mid - 1;
                ans = mid;
            }else low = mid + 1;
        }

        ans = i - ans + 1;
        if(a<=ans){
            a = ans;
            id = num;
        }
    }
    cout << a << ' ' << id << endl;
}


#include <stdio.h>
#include <fstream>
#include <string>
#include <stack>
#include <algorithm>
#include <cmath>
#include <map>
#include <iostream>
#include <set>
#include <iomanip>
#include <vector>

using namespace std;

vector<int> s;

int S(int k)
{
	if (k < 0)
		return 0;
	return s[k];
}

int main()
{
	int n, k;
	cin >> n >> k;
	vector<int> v(n), x(n);
	s.resize(n);
	for (int i = 0; i < n; ++i)
		cin >> v[i];
	sort(v.begin(), v.end());
	s[0] = v[0];
	for (int i = 1; i < n; ++i)
		s[i] = s[i - 1] + v[i];
	for (int i = 1; i < n; ++i)
	{
		int l = 0, r = i;
		while (l < r)
		{
			int m = (l + r)/2;
			int t = (i - m)*v[i] - (S(i - 1) - S(m - 1));
			if (t > k)
				l = m + 1;
			else
				r = m;
		}
		x[i] = i - l;
	}
	int wh = max_element(x.begin(), x.end()) - x.begin();
	cout << x[wh]  + 1 << ' ' << v[wh];
	return 0;
}


#include <stdio.h>
#include <fstream>
#include <string>
#include <stack>
#include <algorithm>
#include <cmath>
#include <map>
#include <iostream>
#include <set>
#include <iomanip>
#include <vector>

using namespace std;

vector<long long> s;

long long S(int k)
{
	if (k < 0)
		return 0;
	return s[k];
}

int main()
{
	long long n, k;
	cin >> n >> k;
	vector<long long> v(n), x(n);
	s.resize(n);
	for (int i = 0; i < n; ++i)
		cin >> v[i];
	sort(v.begin(), v.end());
	s[0] = v[0];
	for (int i = 1; i < n; ++i)
		s[i] = s[i - 1] + v[i];
	for (int i = 1; i < n; ++i)
	{
		int l = 0, r = i;
		while (l < r)
		{
			int m = (l + r)/2;
			long long t = (i - m)*v[i] - (S(i - 1) - S(m - 1));
			if (t > k)
				l = m + 1;
			else
				r = m;
		}
		x[i] = i - l;
	}
	int wh = max_element(x.begin(), x.end()) - x.begin();
	cout << x[wh]  + 1 << ' ' << v[wh];
	return 0;
}


#ifndef SOURCE_IS_SPLICED
#include <functional>
#include <algorithm>
#include <iostream>
#include <sstream>
#include <numeric>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <cstdio>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <list>
#include <map>
#include <set>
using namespace std;typedef long long ll;typedef long double real;void run();int main(){ios::sync_with_stdio(0);run();}
#endif

map<ll,ll> occur;

void run(){
  ll n,m; cin>>n>>m;
  while (n--) {ll x; cin>>x; ++occur[x], occur[x-1];}
  ll best=-1, ben=-1;
  multiset<ll> important;

  ll last=0,cost=0;
  for (auto i: occur){
    cost+=(i.first-last)*important.size();
    last=i.first;

    while (cost>m){
      auto j=important.begin();
      cost-=i.first-*j;
      important.erase(j);
    }
    ll got=important.size()+i.second;
    if (got>best) best=got, ben=i.first;
    while (i.second--) important.insert(i.first);
  }
  cout<<best<<" "<<ben<<endl;
}


#include <bits/stdc++.h>
#define forn(i, n) for(int i = 0; i < (int) n; ++i)
#define ford(i, n) for(int i = (int)(n) - 1; i >= 0; ++i)
#define For(i, st, en) for(int i = (int)st; i <= (int)en; ++i)
#define clr(x) memset(x, 0, sizeof(x))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define x first
#define y second
#define mp make_pair

using namespace std;

typedef unsigned int uint;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef pair<int, int> PII;

/**
 * The code starts here.
 */

int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);

    ll n, k;
    cin >> n >> k;
    ll a[n];
    for (int i = 0; i < n; ++i)
    {
        cin >> a[i];
    }

    sort(a, a + n);

    ll sum[n + 1];
    sum[0] = 0;
    for (int i = 0; i < n; ++i)
    {
        sum[i + 1] = sum[i] + a[i];
    }

    int best = -1;
    int x = -1;
    for (int i = 0; i < n; ++i)
    {
        int l = 0, r = i;
        while (l < r)
        {
            int m = (l + r + 1) >> 1;

            int cn = m * a[i] - (sum[i] - sum[i - m]);
            if (cn > k)
            {
                r = m - 1;
            } else
            {
                l = m;
            }
        }
        int ans = l + 1;
        if (ans > best)
        {
            best = ans;
            x = a[i];
        }
    }

    cout << best << " " << x << endl;
    return 0;
}


#include <bits/stdc++.h>
#define forn(i, n) for(int i = 0; i < (int) n; ++i)
#define ford(i, n) for(int i = (int)(n) - 1; i >= 0; ++i)
#define For(i, st, en) for(int i = (int)st; i <= (int)en; ++i)
#define clr(x) memset(x, 0, sizeof(x))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define x first
#define y second
#define mp make_pair

using namespace std;

typedef unsigned int uint;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef pair<int, int> PII;

/**
 * The code starts here.
 */

int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);

    ll n, k;
    cin >> n >> k;
    ll a[n];
    for (int i = 0; i < n; ++i)
    {
        cin >> a[i];
    }

    sort(a, a + n);

    ll sum[n + 1];
    sum[0] = 0;
    for (int i = 0; i < n; ++i)
    {
        sum[i + 1] = sum[i] + a[i];
    }

    int best = -1;
    int x = -1;
    for (int i = 0; i < n; ++i)
    {
        int l = 0, r = i;
        while (l < r)
        {
            int m = (l + r + 1) >> 1;

            ll cn = m * a[i] - (sum[i] - sum[i - m]);
            if (cn > k)
            {
                r = m - 1;
            } else
            {
                l = m;
            }
        }
        int ans = l + 1;
        if (ans > best)
        {
            best = ans;
            x = a[i];
        }
    }

    cout << best << " " << x << endl;
    return 0;
}


#include <iostream>
#include <algorithm>

using namespace std;

const int max_n = 1e5 + 15;

int n, k, l, r, maxi, sol, niz[max_n];
long long s[max_n];

long long get(int idx)
{
  return idx < 0 ? 0 : s[idx];
}

int main()
{
  cin >> n >> k;
  for (int i = 0; i < n; i++) cin >> niz[i];
  sort(niz, niz + n, greater<int>());
  *s = *niz;
  for (int i = 1; i < n; i++) s[i] = niz[i] + s[i - 1];
  for (int i = 0; i < n; i++)
  {
    for (l = i, r = n - 1; l < r;)
    {
      int mid = (l + r + 1) / 2;
      long long curr = get(mid) - get(i - 1);
      curr = 1LL * (mid - i + 1) * niz[i] - curr;
      if (curr > k) r = mid - 1;
      else l = mid;
    }
    if (l - i + 1 >= maxi) maxi = l - i + 1, sol = niz[i];
  }
  cout << maxi << " " << sol;
  return 0;
}


#include <iostream>
#include <algorithm>

using namespace std;

const int max_n = 1e5 + 15;

int n, k, l, r, maxi, sol, niz[max_n];
long long s[max_n];

long long get(int idx)
{
  return idx < 0 ? 0 : s[idx];
}

int main()
{
  cin >> n >> k;
  for (int i = 0; i < n; i++) cin >> niz[i];
  sort(niz, niz + n, greater<int>());
  *s = *niz;
  for (int i = 1; i < n; i++) s[i] = niz[i] + s[i - 1];
  for (int i = 0; i < n; i++)
  {
    for (l = i, r = n - 1; l < r;)
    {
      int mid = (l + r + 1) / 2;
      long long curr = get(mid) - get(i - 1);
      curr = 1LL * (mid - i + 1) * niz[i] - curr;
      if (curr > k) r = mid - 1;
      else l = mid;
    }
    if (l - i + 1 > maxi) maxi = l - i + 1, sol = niz[i];
  }
  cout << maxi << " " << sol;
  return 0;
}


#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>
#define REP(i,a,n) for(int i = (a); i < (int)(n); ++i)
#define foreach(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
using namespace std;

typedef int (*CMP)(const void *, const void *);
typedef __int64 ll;
typedef unsigned __int64 ull;

template<typename T>
inline T ABS(T a) { return a > 0 ? a : -a; }
template<typename T>
inline T MIN(T a, T b) { return a < b ? a : b; }
template<typename T>
inline T MAX(T a, T b) { return a > b ? a : b; }
template<typename T>
inline T CHKMIN(T &a, T b) { if(a > b) a = b; return a; }
template<typename T>
inline T CHKMAX(T &a, T b) { if(a < b) a = b; return a; }
template<typename T>
inline void SWAP(T &a, T &b) { static T c; c = a; a = b; b = c; }

template<typename T>
T bsrch(T beg, T end, std::function<int(T)> f) {
	T mid;
	while(beg < end) {
		mid = (beg + end) / 2;
		if(f(mid)) {
			end = mid;
		} else {
			beg = mid + 1;
		}
	}
	return end;
}

class MyOut {
public:
#define impl_myout(type) MyOut& operator<< (type val) { cout << val << ' ';	return *this; }
#define impl_myout0(type) MyOut& operator<< (type val) { cout << val;	return *this; }
#define endl '\n'
	impl_myout(bool) impl_myout(short) impl_myout(unsigned short) impl_myout(int) impl_myout(unsigned int)
	impl_myout(long) impl_myout(unsigned long) impl_myout(float) impl_myout(double) impl_myout(long double)
	impl_myout(const void*) impl_myout(ll) impl_myout(ull)
	impl_myout0(char) impl_myout0(char *) impl_myout0(const char *)
}myout;

int n, k, in[200000];
ll s[200000];

int main() {
	while(cin >> n >> k) {
		REP(i, 0, n) scanf("%d", in + i);
		sort(in, in + n);
		s[0] = 0; REP(i, 0, n) s[i + 1] = s[i] + in[i];
		ll tmp;
		ll ans = bsrch<ll>(1, n + 1, [&](ll x) {
			if(x == n + 1) return 0;
			//cout << "x = " << x << endl;
			REP(i, x, n + 1) {
				//myout << i << in[i - 1] << s[i] - s[i - x] + k << 1L * x * in[i - 1] << endl;
				if(s[i] - s[i - x] + k >= x * in[i - 1]) {
					tmp = in[i - 1];
					return 0;
				}
			}
			return 1;
		});
		cout << ans - 1 << ' ' << tmp << endl;
	}
}


#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>
#define REP(i,a,n) for(int i = (a); i < (int)(n); ++i)
#define foreach(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
using namespace std;

typedef int (*CMP)(const void *, const void *);
typedef __int64 ll;
typedef unsigned __int64 ull;

template<typename T>
inline T ABS(T a) { return a > 0 ? a : -a; }
template<typename T>
inline T MIN(T a, T b) { return a < b ? a : b; }
template<typename T>
inline T MAX(T a, T b) { return a > b ? a : b; }
template<typename T>
inline T CHKMIN(T &a, T b) { if(a > b) a = b; return a; }
template<typename T>
inline T CHKMAX(T &a, T b) { if(a < b) a = b; return a; }
template<typename T>
inline void SWAP(T &a, T &b) { static T c; c = a; a = b; b = c; }

template<typename T>
T bsrch(T beg, T end, std::function<int(T)> f) {
	T mid;
	while(beg < end) {
		mid = (beg + end) / 2;
		if(f(mid)) {
			end = mid;
		} else {
			beg = mid + 1;
		}
	}
	return end;
}

class MyOut {
public:
#define impl_myout(type) MyOut& operator<< (type val) { cout << val << ' ';	return *this; }
#define impl_myout0(type) MyOut& operator<< (type val) { cout << val;	return *this; }
#define endl '\n'
	impl_myout(bool) impl_myout(short) impl_myout(unsigned short) impl_myout(int) impl_myout(unsigned int)
	impl_myout(long) impl_myout(unsigned long) impl_myout(float) impl_myout(double) impl_myout(long double)
	impl_myout(const void*) impl_myout(ll) impl_myout(ull)
	impl_myout0(char) impl_myout0(char *) impl_myout0(const char *)
}myout;

int n, k, in[200000];
ll s[200000];

int main() {
	while(cin >> n >> k) {
		REP(i, 0, n) scanf("%d", in + i);
		sort(in, in + n);
		s[0] = 0; REP(i, 0, n) s[i + 1] = s[i] + in[i];
		int tmp;
		int ans = bsrch<int>(1, n + 1, [&](int x) {
			if(x == n + 1) return 0;
			//cout << "x = " << x << endl;
			REP(i, x, n + 1) {
				//myout << i << in[i - 1] << s[i] - s[i - x] + k << 1L * x * in[i - 1] << endl;
				if(s[i] - s[i - x] + k >= 1L * x * in[i - 1]) {
					tmp = in[i - 1];
					return 0;
				}
			}
			return 1;
		});
		cout << ans - 1 << ' ' << tmp << endl;
	}
}


#include <bits/stdc++.h>

#define pb push_back
#define mp make_pair
#define f first
#define s second
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define pi acos(-1.0)
#define EPS 1e-9
typedef long long ll;

using namespace std;
ll arr[100009];
int main()
{
	int n,k;scanf("%d %d",&n,&k);
	vector<int> v(n);for(auto &x:v)scanf("%d",&x);
	sort(all(v));
	memset(arr,0,sizeof(arr));
	for(int i=1;i<n;i++)arr[i]=arr[i-1]+(ll)v[i-1];
	int ans1=0,ans2=0;
	for(int i=0;i<n;i++){
		int low=0,high=i,mx=-1;
		while(low<=high){
			int mid=(low+high)/2;
			ll x=(ll)(i-mid)*(ll)v[i];
			if(x-(arr[i]-arr[mid])<=k)high=mid-1,mx=i-mid+1;
			else low=mid+1;
		}
		if(mx>ans1)ans1=mx,ans2=i;
	}
	printf("%d %d\n",ans1,v[ans2]);
	return 0;
}


#pragma comment(linker, "/STACK:16777216")
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <vector>

using namespace std;

#ifndef ONLINE_JUDGE
#define Eo(x) { cerr << #x << " = " << (x) << endl; }
#else
#define Eo(x)
#endif

typedef long long int64;
const int inf = 0x3f3f3f3f;
const int64 inf64 = 0x3f3f3f3f3f3f3f3fLL;
typedef double real;
const real eps = 1e-6;
typedef pair<int64,int64> pip;

int64 gcd(int64 a, int64 b) {
  return a ? gcd(b%a,a) : b;
}

template <typename A,typename B>
ostream& operator<<(ostream& os, const pair<A,B>& p) {
                 return os << p.first << "," << p.second;
}

template <typename A>
ostream& operator<<(ostream& os, const vector<A>& v) {
                 for (int i = 0; i < v.size(); i++) {
                   os << v[i] << ";";
                 }
                 return os;
}

template <typename A>
ostream& operator<<(ostream& os, const set<A>& v) {
                 for (typename set<A>::const_iterator it = v.begin(); it != v.end(); ++it) {
                   os << *it << ";";
                 }
                 return os;
}

template <typename A, typename B>
ostream& operator<<(ostream& os, const map<A,B>& v) {
                 for (typename map<A,B>::const_iterator it = v.begin(); it != v.end(); ++it) {
                   os << it->first << "=" << it->second << ";";
                 }
                 return os;
}

inline int64 bit(int64 k) {
  return int64(1)<<k;
}

int SolveSquareEquation(real a, real b, real c, real& x1, real& x2) {
  real desc = b*b-4*a*c;
  if (desc<0) return 0;
  real sqrt_desc = sqrt(desc);
  x1 = (-b+sqrt_desc)/(2*a);
  x2 = (-b-sqrt_desc)/(2*a);
  if (desc<eps) {
    return 1;
  }
  return 2;
}

int SolveSquareEquationInt(int64 a, int64 b, int64 c, int64& x1, int64& x2) {
  int64 desc = b*b-4*a*c;
  if (desc<0) return 0;
  real sqrt_desc_r = sqrt(real(desc));
  int64 sqrt_desc = sqrt_desc_r;
  for (;sqrt_desc*sqrt_desc<desc; sqrt_desc++);
  for (;sqrt_desc*sqrt_desc>desc; sqrt_desc--);
  if (sqrt_desc*sqrt_desc != desc) {
    return 0;
  }
  int64 u1 = -b+sqrt_desc;
  int64 u2 = -b-sqrt_desc;
  int64 a2 = a*2;
  vector<int64> res;
  if (!(u1%a2)) {
    res.push_back(u1/a2);
  }
  if (!(u2%a2)) {
    res.push_back(u2/a2);
  }
  int oldsize = res.size();
  res.resize(2);
  x1=res[0];
  x2=res[1];
  return oldsize;
}

int64 a[100100];
int main() {
  int n,q; cin >> n >> q;
  for (int i = 0; i < n; i++) {
    int x; scanf("%d",&x);
    a[i]=x;
  }
  a[n]=-2.0001e9;
  sort(a,a+n+1);
  int64 mx = -1;
  int64 res = -1;
  int64 s = 0;
  int64 cnt = 0;
  int j = n;
  for (int i = n; i > 0; i--) {
    for (;j>=0;j--){
      int64 d = a[i]-a[j];
      if (s+d <= q) {
        s += d;
        cnt++;
      } else {
        break;
      }
    }
    if (cnt >= mx) {
      mx = cnt;
      res = a[i];
    }
    cnt--;
    s -= cnt*(a[i]-a[i-1]);
  }
  cout << mx << " " << res << endl;
  return 0;
}


#pragma comment(linker, "/STACK:16777216")
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <vector>

using namespace std;

#ifndef ONLINE_JUDGE
#define Eo(x) { cerr << #x << " = " << (x) << endl; }
#else
#define Eo(x)
#endif

typedef long long int64;
const int inf = 0x3f3f3f3f;
const int64 inf64 = 0x3f3f3f3f3f3f3f3fLL;
typedef double real;
const real eps = 1e-6;
typedef pair<int64,int64> pip;

int64 gcd(int64 a, int64 b) {
  return a ? gcd(b%a,a) : b;
}

template <typename A,typename B>
ostream& operator<<(ostream& os, const pair<A,B>& p) {
                 return os << p.first << "," << p.second;
}

template <typename A>
ostream& operator<<(ostream& os, const vector<A>& v) {
                 for (int i = 0; i < v.size(); i++) {
                   os << v[i] << ";";
                 }
                 return os;
}

template <typename A>
ostream& operator<<(ostream& os, const set<A>& v) {
                 for (typename set<A>::const_iterator it = v.begin(); it != v.end(); ++it) {
                   os << *it << ";";
                 }
                 return os;
}

template <typename A, typename B>
ostream& operator<<(ostream& os, const map<A,B>& v) {
                 for (typename map<A,B>::const_iterator it = v.begin(); it != v.end(); ++it) {
                   os << it->first << "=" << it->second << ";";
                 }
                 return os;
}

inline int64 bit(int64 k) {
  return int64(1)<<k;
}

int SolveSquareEquation(real a, real b, real c, real& x1, real& x2) {
  real desc = b*b-4*a*c;
  if (desc<0) return 0;
  real sqrt_desc = sqrt(desc);
  x1 = (-b+sqrt_desc)/(2*a);
  x2 = (-b-sqrt_desc)/(2*a);
  if (desc<eps) {
    return 1;
  }
  return 2;
}

int SolveSquareEquationInt(int64 a, int64 b, int64 c, int64& x1, int64& x2) {
  int64 desc = b*b-4*a*c;
  if (desc<0) return 0;
  real sqrt_desc_r = sqrt(real(desc));
  int64 sqrt_desc = sqrt_desc_r;
  for (;sqrt_desc*sqrt_desc<desc; sqrt_desc++);
  for (;sqrt_desc*sqrt_desc>desc; sqrt_desc--);
  if (sqrt_desc*sqrt_desc != desc) {
    return 0;
  }
  int64 u1 = -b+sqrt_desc;
  int64 u2 = -b-sqrt_desc;
  int64 a2 = a*2;
  vector<int64> res;
  if (!(u1%a2)) {
    res.push_back(u1/a2);
  }
  if (!(u2%a2)) {
    res.push_back(u2/a2);
  }
  int oldsize = res.size();
  res.resize(2);
  x1=res[0];
  x2=res[1];
  return oldsize;
}

int main() {
  int n,q; cin >> n >> q;
  map<int,int> all;
  for (int i = 0; i < n; i++) {
    int x; scanf("%d",&x);
    all[x]++;
  }
  int mx = -1;
  int res = -1;
  all[-inf]=1;
  int64 s = 0;
  int cnt = 0;
  vector<pair<int,int>> vall(all.begin(),all.end());
  int j = vall.size();
  for (int i = vall.size()-1; i > 0; i--) {
    if (j >= i) {
      s = 0;
      cnt = vall[i].second;
      j = i-1;
    }
    int last = 0;
    int64 lastdiff = 0;
    for (;j>=0;j--){
      int64 d = vall[i].first-vall[j].first;
      int64 k = vall[j].second;
      if (s+d*k <= q) {
        s += d*k;
        cnt += k;
        last = k;
        lastdiff = d;
      } else {
        int64 canbe = (q-s)/d;
        s += d*canbe;
        cnt += canbe;
        last = canbe;
        lastdiff = d;
        break;
      }
    }
    if (cnt >= mx) {
      mx = cnt;
      res = vall[i].first;
    }
      cnt -= vall[i].second;
      s -= lastdiff*last;
      cnt -= last;
      int64 d = vall[i].first-vall[i-1].first;
      int64 k1 = vall[i].first;
      s -= d*cnt;
  }
  cout << mx << " " << res << endl;
  return 0;
}


#pragma comment(linker, "/STACK:16777216")
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <vector>

using namespace std;

#ifndef ONLINE_JUDGE
#define Eo(x) { cerr << #x << " = " << (x) << endl; }
#else
#define Eo(x)
#endif

typedef long long int64;
const int inf = 0x3f3f3f3f;
const int64 inf64 = 0x3f3f3f3f3f3f3f3fLL;
typedef double real;
const real eps = 1e-6;
typedef pair<int64,int64> pip;

int64 gcd(int64 a, int64 b) {
  return a ? gcd(b%a,a) : b;
}

template <typename A,typename B>
ostream& operator<<(ostream& os, const pair<A,B>& p) {
                 return os << p.first << "," << p.second;
}

template <typename A>
ostream& operator<<(ostream& os, const vector<A>& v) {
                 for (int i = 0; i < v.size(); i++) {
                   os << v[i] << ";";
                 }
                 return os;
}

template <typename A>
ostream& operator<<(ostream& os, const set<A>& v) {
                 for (typename set<A>::const_iterator it = v.begin(); it != v.end(); ++it) {
                   os << *it << ";";
                 }
                 return os;
}

template <typename A, typename B>
ostream& operator<<(ostream& os, const map<A,B>& v) {
                 for (typename map<A,B>::const_iterator it = v.begin(); it != v.end(); ++it) {
                   os << it->first << "=" << it->second << ";";
                 }
                 return os;
}

inline int64 bit(int64 k) {
  return int64(1)<<k;
}

int SolveSquareEquation(real a, real b, real c, real& x1, real& x2) {
  real desc = b*b-4*a*c;
  if (desc<0) return 0;
  real sqrt_desc = sqrt(desc);
  x1 = (-b+sqrt_desc)/(2*a);
  x2 = (-b-sqrt_desc)/(2*a);
  if (desc<eps) {
    return 1;
  }
  return 2;
}

int SolveSquareEquationInt(int64 a, int64 b, int64 c, int64& x1, int64& x2) {
  int64 desc = b*b-4*a*c;
  if (desc<0) return 0;
  real sqrt_desc_r = sqrt(real(desc));
  int64 sqrt_desc = sqrt_desc_r;
  for (;sqrt_desc*sqrt_desc<desc; sqrt_desc++);
  for (;sqrt_desc*sqrt_desc>desc; sqrt_desc--);
  if (sqrt_desc*sqrt_desc != desc) {
    return 0;
  }
  int64 u1 = -b+sqrt_desc;
  int64 u2 = -b-sqrt_desc;
  int64 a2 = a*2;
  vector<int64> res;
  if (!(u1%a2)) {
    res.push_back(u1/a2);
  }
  if (!(u2%a2)) {
    res.push_back(u2/a2);
  }
  int oldsize = res.size();
  res.resize(2);
  x1=res[0];
  x2=res[1];
  return oldsize;
}

int64 a[100100];
int main() {
  int n,q; cin >> n >> q;
  for (int i = 0; i < n; i++) {
    int x; scanf("%d",&x);
    a[i]=x;
  }
  a[n]=-inf;
  sort(a,a+n+1);
  int64 mx = -1;
  int64 res = -1;
  int64 s = 0;
  int64 cnt = 0;
  int j = n;
  for (int i = n; i > 0; i--) {
    for (;j>=0;j--){
      int64 d = a[i]-a[j];
      if (s+d <= q) {
        s += d;
        cnt++;
      } else {
        break;
      }
    }
    if (cnt >= mx) {
      mx = cnt;
      res = a[i];
    }
    cnt--;
    s -= cnt*(a[i]-a[i-1]);
  }
  cout << mx << " " << res << endl;
  return 0;
}


#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <cmath>
#include <climits>
#include <string>
#include <cctype>
#include <ctime>
#include <sstream>
#include <algorithm>
#include <list>
#include <cstring>
#include <map>
using namespace std;

// <editor-fold defaultstate="collapsed" desc="Defines">

typedef long long ll;
typedef unsigned long long ull;
typedef vector<double> vd;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
const double PI = 3.14159265358979;
const double PI2 = 6.28318530717958;
const double PId2 = 1.570796326794895;
#define REP(to, counter) for (int counter=0; counter < int(to); counter++)
#define X first
#define PB push_back
#define MP make_pair
#define Y second
#define eps 1E-7

inline ll pw(ll n, int p)
{
    ll ans = 1;
    for (int i = 0; i < p; i++) ans *= n;
    return ans;
}

inline vi ReadVI(int count)
{
    vi arrayname(count);
    REP(count, i) cin >> arrayname[i];
    return arrayname;
};

inline vii ReadVII(int count)
{
    vii arrayname(count);

    REP(count, i)
    {
        cin >> arrayname[i].first;
        arrayname[i].second = i;
    }
    return arrayname;
};

const int MOD = 1000000007;
const int MAXVALUE = 101;

// </editor-fold >

int main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
#endif
    int n, k;
    cin >> n >> k;
    vi a = ReadVI(n);
    sort(a.begin(), a.end());

    int l = 0, r = 0, s = 0, p = 1, m = a[l], pm = 0, mm = 0;

    while (l < n - 1 && r < n - 1) {
        if (s <= k) {
            r++;
            s = s + (a[r] - a[r - 1]) * p;
        } else {
            l++;
            s = s - (a[r] - a[l - 1]);
        }
        if (s <= k) {
            p = r - l + 1;
            m = a[r];
            if (p > pm) {
                pm = p;
                mm = m;
            }
        }
    }
    printf("%d %d", pm, mm);
}


#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <cmath>
#include <climits>
#include <string>
#include <cctype>
#include <ctime>
#include <sstream>
#include <algorithm>
#include <list>
#include <cstring>
#include <map>
using namespace std;

// <editor-fold defaultstate="collapsed" desc="Defines">

typedef long long ll;
typedef unsigned long long ull;
typedef vector<double> vd;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
const double PI = 3.14159265358979;
const double PI2 = 6.28318530717958;
const double PId2 = 1.570796326794895;
#define REP(to, counter) for (int counter=0; counter < int(to); counter++)
#define X first
#define PB push_back
#define MP make_pair
#define Y second
#define eps 1E-7

inline ll pw(ll n, int p)
{
    ll ans = 1;
    for (int i = 0; i < p; i++) ans *= n;
    return ans;
}

inline vi ReadVI(int count)
{
    vi arrayname(count);
    REP(count, i) cin >> arrayname[i];
    return arrayname;
};

inline vii ReadVII(int count)
{
    vii arrayname(count);

    REP(count, i)
    {
        cin >> arrayname[i].first;
        arrayname[i].second = i;
    }
    return arrayname;
};

const int MOD = 1000000007;
const int MAXVALUE = 101;

// </editor-fold >

int main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
#endif
    int n, k;
    cin >> n >> k;
    vi a = ReadVI(n);
    sort(a.begin(), a.end());

    int l = 0, r = 0, s = 0, p = 1, m = a[l], pm = 0, mm = 0;

    while (l < n && r < n) {
        if (s <= k) {
            r++;
            s = s + (a[r] - a[r - 1]) * p;
        } else {
            l++;
            s = s - (a[r] - a[l - 1]);
        }
        if (s <= k) {
            p = r - l + 1;
            m = a[r];
            if (p > pm) {
                pm = p;
                mm = m;
            }
        }
    }
    printf("%d %d", pm, mm);

}


#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <cmath>
#include <climits>
#include <string>
#include <cctype>
#include <ctime>
#include <sstream>
#include <algorithm>
#include <list>
#include <cstring>
#include <map>
using namespace std;

// <editor-fold defaultstate="collapsed" desc="Defines">

typedef long long ll;
typedef unsigned long long ull;
typedef vector<double> vd;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
const double PI = 3.14159265358979;
const double PI2 = 6.28318530717958;
const double PId2 = 1.570796326794895;
#define REP(to, counter) for (int counter=0; counter < int(to); counter++)
#define X first
#define PB push_back
#define MP make_pair
#define Y second
#define eps 1E-7

inline ll pw(ll n, int p)
{
    ll ans = 1;
    for (int i = 0; i < p; i++) ans *= n;
    return ans;
}

inline vi ReadVI(int count)
{
    vi arrayname(count);
    REP(count, i) cin >> arrayname[i];
    return arrayname;
};

inline vll ReadVlong(int count)
{
    vll arrayname(count);
    REP(count, i) cin >> arrayname[i];
    return arrayname;
};

inline vii ReadVII(int count)
{
    vii arrayname(count);

    REP(count, i)
    {
        cin >> arrayname[i].first;
        arrayname[i].second = i;
    }
    return arrayname;
};

const int MOD = 1000000007;
const int MAXVALUE = 101;

// </editor-fold >

int main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
#endif
    ll n, k;
    cin >> n >> k;
    vll a = ReadVlong(n);
    sort(a.begin(), a.end());

    ll l = 0, r = 0, s = 0, p = 1, m = a[l], pm = 1, mm = a[r];

    while (l < n - 1 && r < n - 1) {
        if (s <= k) {
            r++;
            s = s + (a[r] - a[r - 1]) * p;
        } else {
            l++;
            s = s - (a[r] - a[l - 1]);
        }
        if (s <= k) {
            p = r - l + 1;
            m = a[r];
            if (p > pm) {
                pm = p;
                mm = m;
            }
        }
    }
    printf("%I64d %I64d", pm, mm);
}


#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <cmath>
#include <climits>
#include <string>
#include <cctype>
#include <ctime>
#include <sstream>
#include <algorithm>
#include <list>
#include <cstring>
#include <map>
using namespace std;

// <editor-fold defaultstate="collapsed" desc="Defines">

typedef long long ll;
typedef unsigned long long ull;
typedef vector<double> vd;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
const double PI = 3.14159265358979;
const double PI2 = 6.28318530717958;
const double PId2 = 1.570796326794895;
#define REP(to, counter) for (int counter=0; counter < int(to); counter++)
#define X first
#define PB push_back
#define MP make_pair
#define Y second
#define eps 1E-7

inline ll pw(ll n, int p)
{
    ll ans = 1;
    for (int i = 0; i < p; i++) ans *= n;
    return ans;
}

inline vi ReadVI(int count)
{
    vi arrayname(count);
    REP(count, i) cin >> arrayname[i];
    return arrayname;
};

inline vll ReadVlong(int count)
{
    vll arrayname(count);
    REP(count, i) cin >> arrayname[i];
    return arrayname;
};

inline vii ReadVII(int count)
{
    vii arrayname(count);

    REP(count, i)
    {
        cin >> arrayname[i].first;
        arrayname[i].second = i;
    }
    return arrayname;
};

const int MOD = 1000000007;
const int MAXVALUE = 101;

// </editor-fold >

int main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
#endif
    ll n, k;
    cin >> n >> k;
    vll a = ReadVlong(n);
    sort(a.begin(), a.end());

    ll l = 0, r = 0, s = 0, p = 1, m = a[l], pm = 0, mm = 0;

    while (l < n - 1 && r < n - 1) {
        if (s <= k) {
            r++;
            s = s + (a[r] - a[r - 1]) * p;
        } else {
            l++;
            s = s - (a[r] - a[l - 1]);
        }
        if (s <= k) {
            p = r - l + 1;
            m = a[r];
            if (p > pm) {
                pm = p;
                mm = m;
            }
        }
    }
    printf("%I64d %I64d", pm, mm);
}


#include <iostream>
#include <cstdio>

#include <algorithm>

using namespace std;

const int maxn = 100100;
long long n, k, sol, pos;
long long a[maxn], sum[maxn];

inline int binsrc(const int &position) {
	int i = 0, cnt = 1 << 20;
	for (; cnt; cnt >>= 1) {
		int nv = i + cnt;
		if (nv <= n and nv <= position) {
			int cost = sum[position] - sum[position - nv];
			cost = a[position] * nv - cost;
			if (cost <= k) {
				i += cnt;
			}
		}
	}
	return i;
}

int main() {
	scanf("%i %i", &n, &k);
	for (int i = 1; i <= n; ++i) {
		scanf("%i", &a[i]);
	}
	sort(a + 1, a + n + 1);

	for (int i = 1; i <= n; ++i) {
		sum[i] = sum[i - 1] + a[i];
	}

	for (int i = 1; i <= n; ++i) {
		long long value = binsrc(i);
		if (sol < value) {
			sol = value;
			pos = a[i];
		}
	}

	printf("%i %i\n", sol, pos);
}


#include <iostream>
#include <cstdio>

#include <algorithm>

using namespace std;

const int maxn = 100100;
long long n, k, sol, pos;
long long a[maxn], sum[maxn];

inline int binsrc(const int &position) {
    int i = 0, cnt = 1 << 20;
    for (; cnt; cnt >>= 1) {
        int nv = i + cnt;
        if (nv <= n and nv <= position) {
            long long cost = sum[position] - sum[position - nv];
            cost = a[position] * nv - cost;
            if (cost <= k) {
                i += cnt;
            }
        }
    }
    return i;
}

int main() {
    cin >> n >> k;
    for (int i = 1; i <= n; ++i) {
        cin >> a[i];
    }
    sort(a + 1, a + n + 1);

    for (int i = 1; i <= n; ++i) {
        sum[i] = sum[i - 1] + a[i];
    }

    for (int i = 1; i <= n; ++i) {
        long long value = binsrc(i);
        if (sol < value) {
            sol = value;
            pos = a[i];
        }
    }

    cout << sol << ' ' << pos << '\n';
}


#include <iostream>
#include <cstdio>

#include <algorithm>

using namespace std;

const int maxn = 100100;
long long n, k, sol, pos;
long long a[maxn], sum[maxn];

inline int binsrc(const int &position) {
	int i = 0, cnt = 1 << 20;
	for (; cnt; cnt >>= 1) {
		int nv = i + cnt;
		if (nv <= n and nv <= position) {
			int cost = sum[position] - sum[position - nv];
			cost = a[position] * nv - cost;
			if (cost <= k) {
				i += cnt;
			}
		}
	}
	return i;
}

int main() {
	cin >> n >> k;
	for (int i = 1; i <= n; ++i) {
		cin >> a[i];
	}
	sort(a + 1, a + n + 1);

	for (int i = 1; i <= n; ++i) {
		sum[i] = sum[i - 1] + a[i];
	}

	for (int i = 1; i <= n; ++i) {
		long long value = binsrc(i);
		if (sol < value) {
			sol = value;
			pos = a[i];
		}
	}

	cout << sol << ' ' << pos << '\n';
}


#include <iostream>
#include <math.h>
#include <string>
#include <algorithm>
#include <vector>
using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::pair;
using std::vector;

int main()
{
   //freopen("input.txt", "r", stdin);
   // freopen("output.txt", "w", stdout);
    int  n,m = 0;
    cin>>n>>m;

    //std::vector <int> intvec2(n);
    //std::vector <int> intvec4(m);
    int answer1 = 0;
    int answer2 = 0;
    int a = 0;
    std::vector <int> intvec7(0);
    std::vector <int> intvec8(0);

    for(int i = 0; i<n; i++)
    {

        cin>>a;
        int tmp = a;
        cin>>a;
        tmp+=a*10000;
        intvec7.push_back(tmp);

    }

std::sort(intvec7.begin(), intvec7.end());
int ind = 0;
int ind2 = n;

        for(int i = 0; i<m; i++)
    {
        a = 0;
        cin>>a;
        int tmp = a;
        bool put = false;
        cin>>a;
        tmp+=a*10000;
        //intvec8.push_back(tmp);
        ind++;
        for(int j = 0; j<ind2; j++)
        {
            if(intvec7[j]==tmp)
            {

                answer2++;

                intvec7.erase(intvec7.begin()+j);
                ind2--;
                put = true;
                //intvec8.pop_back();
                ind--;
                break;
            }

            if(intvec7[j]>tmp)
            {
                break;
            }

        }
        if(put==false)
        {
            intvec8.push_back(tmp);
        }

    }
        std::sort(intvec8.begin(), intvec8.end());
        int index = 0;
        int tmpindex = ind2;
        answer1=answer2;
        for(int i = index; i<ind; i++)
            for(int j = 0; j<ind2; j++)
        {

            //if(intvec8[i]-floor(intvec8[i])!=0)
            //{
            //  break;
            //}
            if(intvec7[j]/10000>intvec8[i]/10000)
            {
                break;
            }

            if(intvec7[j]/10000==intvec8[i]/10000)
            {
                //answer1++;
                intvec7.erase(intvec7.begin()+j);
                ind2--;
                if(j<index)
                    index--;
                break;
            }
            if(intvec7[j]/10000<intvec8[i]/10000)
            {
                index++;
            }
        }
        answer1+=tmpindex-ind2;

        cout<<answer1<<" "<<answer2;
    //      system("pause");

    return 0;
}


#include <iostream>
#include <math.h>
#include <string>
#include <algorithm>
#include <vector>
using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::pair;
using std::vector;

bool SortPair(const std::pair <int, int> &p1, const std::pair <int, int> &p2)
{
    return p1.second < p2.second;
}

int main()
{
  //  freopen("input.txt", "r", stdin);
   // freopen("output.txt", "w", stdout);
	int  n,m = 0;
	cin>>n>>m;

	std::vector <pair<int, int>> intvec(n);
	std::vector <pair<int, int>> intvec3(m);
	std::vector <int> intvec2(n);
	std::vector <int> intvec4(m);
	std::vector <int> intvec5(n);
	std::vector <int> intvec6(m);
	std::vector <int> intvec7(n);
	std::vector <int> intvec8(m);

	for(int i = 0; i<n; i++)
	{
		int a = 0;
		cin>>a;
		intvec[i].first = a;
		cin>>a;
		intvec[i].second = a;

	}

std::sort(intvec.begin(), intvec.end(), SortPair);
			for(int i = 0; i<n; i++)
	{
		intvec2[i]=intvec[i].first*10000+intvec[i].second;

	}

		for(int i = 0; i<m; i++)
	{
		int a = 0;
		cin>>a;
		intvec3[i].first = a;
		cin>>a;
		intvec3[i].second = a;

	}
std::sort(intvec3.begin(), intvec3.end(), SortPair);

			for(int i = 0; i<m; i++)
	{
		intvec4[i]=intvec3[i].first*10000+intvec3[i].second;

	}
std::sort(intvec4.begin(), intvec4.end());

			for(int i = 0; i<n;i++)
			{
						intvec5[i]=intvec[i].first;
						intvec7[i]=intvec[i].second;

			}

			for(int i = 0; i<m;i++)
			{
						intvec6[i]=intvec3[i].first;
						intvec8[i]=intvec3[i].second;

			}
		int answer1 = 0;
			int answer2 = 0;

		for(int i = 0; i<n; i++)
		{
			if(std::binary_search(intvec4.begin(), intvec4.end(), intvec2[i]))
			{

				for(int j = 0; j<m; j++)
				{
					if(intvec2[i]==intvec4[j])
					{
				//	answer1++;
					answer2++;
					intvec4[j]=0;
					std::sort(intvec4.begin(), intvec4.end());
					break;
					}
				}

				}

			}

		for(int i = 0; i<n; i++)
		{

		if(std::binary_search(intvec8.begin(), intvec8.end(), intvec7[i]))
			{
for(int j = 0; j<m; j++)
			{
			if(intvec8[j]==intvec7[i])
				{

					answer1++;
				//	answer2++;
					intvec8[j]=0;
					std::sort(intvec8.begin(), intvec8.end());
					break;
				}
			}
			}

		}
		cout<<answer1<<" "<<answer2;
		//	system("pause");

	return 0;
}


#include <iostream>
#include <math.h>
#include <string>
#include <algorithm>
#include <vector>
using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::pair;
using std::vector;

int main()
{
   //freopen("input.txt", "r", stdin);
   // freopen("output.txt", "w", stdout);
    int  n,m = 0;
    cin>>n>>m;

    //std::vector <int> intvec2(n);
    //std::vector <int> intvec4(m);
    int answer1 = 0;
    int answer2 = 0;

    std::vector <double> intvec7(n);
    std::vector <double> intvec8(0);

    for(int i = 0; i<n; i++)
    {
        int a = 0;
        cin>>a;
        intvec7[i] = a;
        cin>>a;
        intvec7[i]+= a*10000;

    }

std::sort(intvec7.begin(), intvec7.end());
int ind = 0;
int ind2 = n;

        for(int i = 0; i<m; i++)
    {
        int a = 0;
        cin>>a;
        int tmp = a;

        cin>>a;
        tmp+=a*10000;
        intvec8.push_back(tmp);
        ind++;
        for(int j = 0; j<ind2; j++)
        {
            if(intvec7[j]==intvec8[ind-1])
            {
                answer1++;
                answer2++;
            //  intvec7[j]-=0.5;
                intvec7.erase(intvec7.begin()+j);
                ind2--;
                intvec8.pop_back();
                ind--;
                break;
            }
            if(intvec7[j]>intvec8[ind-1])
            {
                break;
            }

        }

    }
        for(int i = 0; i<ind; i++)
            for(int j = 0; j<ind2; j++)
        {

            //if(intvec8[i]-floor(intvec8[i])!=0)
            //{
            //  break;
            //}
            if((int)intvec7[j]/10000>(int)intvec8[i]/10000)
            {
                break;
            }
            double g =intvec7[j]/10000;
            double g2=  intvec8[i]/10000;
            double g3 = intvec7[j]-floor(intvec7[j]);
            if((int)(intvec7[j]/10000)==(int)(intvec8[i]/10000)&&intvec7[j]-floor(intvec7[j])==0)
            {
                answer1++;

                intvec7[j]-=0.5;

                break;
            }
        }

        cout<<answer1<<" "<<answer2;
          //  system("pause");

    return 0;
}


#include <iostream>
#include <stdio.h>
#include <fstream>
#include <cmath>
#include <string>
#include <algorithm>

using namespace std;

int marker[1001][1001],cap[1001][1001];

int main(){

		ios_base::sync_with_stdio(0);

		//cout<<"**********OUT PUT BY FILE**********"<<endl;
		//ifstream cin("input.txt");

		int n,m,close=0,bclose=0;

		cin>>n>>m;
		for(int i=0;i<n;i++){
				int x,y;
				cin>>x>>y;
				marker[y][x] ++;
		}
		for(int i=0;i<m;i++){
				int a,b;
				cin>>a>>b;
				cap[b][a]++;
		}

		for(int i=1;i<=1000;i++){
				int sumcap=0,summark=0;
				for(int j=1;j<=1000;j++){
						summark += marker[i][j];
						sumcap += cap[i][j];
						bclose += min(cap[i][j],marker[i][j]);
				}
				close += min(summark,sumcap);
		}

		cout<<close<<" "<<bclose;

		return 0;
}


#include<stdio.h>
int stat1[1001],stat2[1001][1001];
int main()
{
    int n,m,a,b,i,ans1=0,ans2=0;
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    scanf("%d%d",&n,&m);
    for(i=0;i<n;++i)
    {
        scanf("%d%d",&a,&b);
        stat1[b]++;
        stat2[b][a]++;
    }
    for(i=0;i<m;++i)
    {
        scanf("%d%d",&a,&b);
        if(stat1[b])
            stat1[b]--,ans1++;
        if(stat2[b][a])
            stat2[b][a]--,ans2++;
    }
    printf("%d %d\n",ans1,ans2);
}


#include <iostream>
#include <stdio.h>
#include <fstream>
#include <cmath>
#include <string>
#include <algorithm>

using namespace std;

int marker[1001][1001],cap[1001][1001];

int main(){

		ios_base::sync_with_stdio(0);

		//cout<<"*************OUT PUT BY FILE*************"<<endl;
		//ifstream cin("input.txt");

		int n,m,close=0,bclose=0;

		cin>>n>>m;
		for(int i=0;i<n;i++){
				int x,y;
				cin>>x>>y;
				marker[y][x] ++;
		}
		for(int i=0;i<m;i++){
				int a,b;
				cin>>a>>b;
				cap[b][a]++;
		}

		for(int i=1;i<=1000;i++){
				int sumcap=0,summark=0;
				for(int j=1;j<=1000;j++){
						summark += marker[i][j];
						sumcap += cap[i][j];
						bclose += min(cap[i][j],marker[i][j]);
				}
				close += min(summark,sumcap);
		}

		cout<<close<<" "<<bclose;

		return 0;
}


#include <iostream>
#include <iterator>
#include <algorithm>
#include <set>
using namespace std;

set<int> a,b;

int main()
{
    int c[1010]={0}, d[1010]={0};
    int m,n, x,y;
    cin >> n >> m;
    int l = m+n;
    for(int i = 0; i < n; i ++)
    {
        cin >> x >> y;
        c[y] ++;
        a.insert(x*1000+y);
    }
    for(int i = 0; i < m; i ++)
    {
        cin >> x >> y;
        d[y] ++;
        b.insert(x*1000+y);
    }
    int r1=0, r2=0;
    for (int i = 1; i <= 1000; i ++)
    {
        r1 += min(c[i],d[i]);
    }
    set<int> r;
    set_intersection(a.begin(), a.end(), b.begin(), b.end(), inserter(r, r.begin()));
    cout << r1 << " " << r.size();
    return 0;
}


#include <iostream>
#include <iterator>
#include <algorithm>
#include <map>
//#include <utility>
//#include <set>
using namespace std;

int main()
{
    map<int,int> a,b;
    int c[1010]={0}, d[1010]={0};
    int m,n, x,y;
    cin >> n >> m;
    int l = m+n;
    int r1=0, r2=0;
    for(int i = 0; i < n; i ++)
    {
        cin >> x >> y;
        c[y] ++;
        a[1000*x+y]++;
    }
    for(int i = 0; i < m; i ++)
    {
        cin >> x >> y;
        if(c[y]>0)
            c[y]--, r1++;
        if(a[1000*x+y]>0)
            a[1000*x+y]--, r2++;
    }
    cout << r1 << " " << r2;
    return 0;
}


#include<iostream>
#include<set>
#include<utility>
#include<algorithm>
#include<math.h>

#define mp make_pair

using namespace std;

set < pair< int, int > > pen;
set < pair< int, int > > :: iterator cur;
int n,m,i,j,x,y,kol=0,beautykol=0;
int a[1010],b[1010];

int main()
{
	cin>>n>>m;
	for(i=1;i<=n;i++)
	{
		cin>>y>>x;
		pen.insert( mp(x,y) );
		a[x]++;
	}
	for(i=1;i<=m;i++)
	{
		cin>>y>>x;
		cur = pen.find( mp(x,y) );
		if (cur != pen.end())
		{
			if(a[x]==1)	pen.erase(cur);
			a[x]--;
			kol++;
			beautykol++;
		}
		else b[x]++;
	}
	for(i=1;i<=1000;i++)
		kol+=min(a[i],b[i]);
	cout<< kol <<" "<< beautykol;

	return 0;
}


#include<iostream>
#include<set>
#include<utility>
#include<algorithm>
#include<math.h>

#define mp make_pair

using namespace std;

set < pair< int, int > > pen;
set < pair< int, int > > :: iterator cur;
int n,m,i,j,x,y,kol=0,beautykol=0;
int a[1010],b[1010];

int main()
{
	cin>>n>>m;
	for(i=1;i<=n;i++)
	{
		cin>>y>>x;
		pen.insert( mp(x,y) );
		a[x]++;
	}
	for(i=1;i<=m;i++)
	{
		cin>>y>>x;
		cur = pen.find( mp(x,y) );
		if (cur != pen.end())
		{
			pen.erase(cur);
			a[x]--;
			kol++;
			beautykol++;
		}
		else b[x]++;
	}
	for(i=1;i<=1000;i++)
		kol+=min(a[i],b[i]);
	cout<< kol <<" "<< beautykol;

	return 0;
}


#include<iostream>
#include<set>
#include<utility>
#include<algorithm>
#include<math.h>

#define mp make_pair

using namespace std;

set < pair< int, int > > pen;
set < pair< int, int > > :: iterator cur;
int n,m,i,j,x,y,kol=0,beautykol=0;
int a[1010][1010],b[1010];

int main()
{
	cin>>n>>m;
	for(i=1;i<=n;i++)
	{
		cin>>y>>x;
		pen.insert( mp(x,y) );
		a[x][0]++;
		a[x][y]++;
	}
	for(i=1;i<=m;i++)
	{
		cin>>y>>x;
		cur = pen.find( mp(x,y) );
		if (cur != pen.end())
		{
			if(a[x][y]==1)	pen.erase(cur);
			a[x][y]--;
			a[x][0]--;
			kol++;
			beautykol++;
		}
		else b[x]++;
	}
	for(i=1;i<=1000;i++)
		kol+=min(a[i][0],b[i]);
	cout<< kol <<" "<< beautykol;

	return 0;
}


// B.cpp : Defines the entry point for the console application.
//

//#include "stdafx.h"
#include <iostream>
#include <algorithm>
#include <memory.h>

using namespace std;

int caps[1001][1001];
int pens[1001][1001];

int main()
{
	int n, m;
	cin >> n >> m;

	memset(caps, 0, sizeof(caps));
	memset(pens, 0, sizeof(pens));

	for(int i = 0; i < n; i++)
	{
		int x, y;
		cin >> x >> y;
		caps[y][x]++;
	}

	for(int i = 0; i < m; i++)
	{
		int a, b;
		cin >> a >> b;
		pens[b][a]++;
	}

	int beautyful = 0;
	int total = 0;
	for(int i = 1; i <= 1000; i++)
	{
		int total_cap = 0;
		int total_pen = 0;

		for(int j = 1; j <= 1000; j++)
		{
			total_cap += caps[i][j];
			total_pen += pens[i][j];
			beautyful += min(caps[i][j], pens[i][j]);
		}

		total += min(total_cap, total_pen);
	}

	cout << total << " " << beautyful << endl;
	return 0;
}


// B.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <iostream>
#include <algorithm>
#include <memory.h>

using namespace std;

int caps[1001][1001];
int pens[1001][1001];

int main()
{
	int n, m;
	cin >> n >> m;

	memset(caps, 0, sizeof(caps));
	memset(pens, 0, sizeof(pens));

	for(int i = 0; i < n; i++)
	{
		int x, y;
		cin >> x >> y;
		caps[y][x]++;
	}

	for(int i = 0; i < m; i++)
	{
		int a, b;
		cin >> a >> b;
		pens[b][a]++;
	}

	int beautyful = 0;
	int total = 0;
	for(int i = 1; i <= 1000; i++)
	{
		int total_cap = 0;
		int total_pen = 0;

		for(int j = 1; j <= 1000; j++)
		{
			total_cap += caps[i][j];
			total_pen += pens[i][j];
			beautyful += min(caps[i][j], pens[i][j]);
		}

		total += min(total_cap, total_pen);
	}

	cout << total << " " << beautyful << endl;
	return 0;
}


// VK_Cup_2-2.cpp: определяет точку входа для консольного приложения.
//

#include <iostream>
#include <vector>
using namespace std;

struct Data {
	int diam;
	int col;
	bool is_locked;
	Data(){}
};

class PenSet {
	Data *pen;
	Data *cap;
	int n;
	int m;
public:
	int countOfLocked;
	int countOfBeauty;
	PenSet();
	vector<int> CandidatesForBeauty(int);
	int findCapForBeauty(int, vector<int>);
	void getCountOfLockedAndBeautyPens();
	void getCountOfAllLockedPens();
};

PenSet::PenSet()
{
	cin>>n>>m;
	pen = new Data[n];
	for(int i=0 ; i<n ; i++)
	{
		cin>>pen[i].col;
		cin>>pen[i].diam;
		pen[i].is_locked = false;
	}

	cap = new Data[m];
	for(int i=0 ; i<m ; i++)
	{
		cin>>cap[i].col;
		cin>>cap[i].diam;
		cap[i].is_locked = false;
	}

	countOfLocked = 0;
	countOfBeauty = 0;
}

vector<int> PenSet::CandidatesForBeauty(int x)
{
	vector<int> v;

	for(int i=0 ; i<m ; i++)
		if( !cap[i].is_locked && (pen[x].diam == cap[i].diam) )
			v.push_back(i);

	return v;
}

int PenSet::findCapForBeauty(int x, vector<int> v)
{
	vector<int>::iterator it=v.begin();
	for(; it!=v.end() ; it++)
		if( pen[x].col == cap[(*it)].col )
			return *it;

	if( it == v.end() )
		return -1;
}

void PenSet::getCountOfLockedAndBeautyPens()
{
	for(int i=0 ; i<n ; i++)
	{
		if( !pen[i].is_locked )
		{
			vector<int> v = CandidatesForBeauty(i);

			if( !v.empty() )
			{
				int NumOfBeauty = findCapForBeauty(i,v);

				if ( NumOfBeauty!=-1 )
				{
					countOfLocked++;
					countOfBeauty++;
					pen[i].is_locked = true;
					cap[NumOfBeauty].is_locked = true;
				}

				v.clear();
			}
			else
				pen[i].is_locked = true;
		}
	}
}

void PenSet::getCountOfAllLockedPens()
{
	for(int i=0 ; i<n ; i++)
		if( !pen[i].is_locked )
		{
			for(int j=0 ; j<m ; j++)
				if( !cap[j].is_locked && (cap[j].diam == pen[i].diam) )
				{
					pen[i].is_locked = true;
					cap[j].is_locked = true;
					countOfLocked++;
					break;
				}
		}
}

int main()
{
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	PenSet PS1;
	PS1.getCountOfLockedAndBeautyPens();
	PS1.getCountOfAllLockedPens();
	cout<<PS1.countOfLocked<<' '<<PS1.countOfBeauty;
	//fclose(stdin);
	/fclose(stdout);
	return 0;
}