#include<bits/stdc++.h>
#define nl              cout<<"\n"
#define sz(x)           (int)((x).size())
#define len(x)          (x).length()
#define all(a)          (a).begin(),(a).end()
#define rep(i,n)        for( int i=0;i<(int)(n);i++)
#define brep(i,n)       for( int i=(n);i>=0;i-- )
#define repp(i,a,b)     for( int i = (a); i < (b); i++ )
#define ll      long long int
#define pb      push_back
#define mp      make_pair
#define F       first
#define S       second
#define vi      vector<int>
#define vll     vector<ll>
#define pii     pair<int,int>
#define vpii    vector<pair<int,int> >
#define bits    __builtin_popcountll
#define mod     1000000007
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define test int tes; cin >> tes; while( tes-- > 0 )
#define pv(x) cout<< #x<< " = "<<(x)<<"\n";
#define foreach(i,t) for (typeof(t.begin()) i=t.begin(); i!=t.end(); i++)
#ifndef ONLINE_JUDGE
bool ipfile = freopen("ip.txt","r",stdin);
bool opfile = freopen("op.txt","w",stdout);
#endif
using namespace std;
int n,m,x,y,t,q;

double ans,h,l;

int main()
{
    fast
    while(cin>>n>>m)
    {
        map<int,int>M;
        rep(i,n)
            cin>>q , M[q]++;
        x = 8*m - n;
        y=0, t=0;
        vi F;
        int tot_sum = 0;
        for(map<int,int>::iterator it = M.begin();it!= M.end();++it)
            F.pb(it->S) , tot_sum += it->S;
        int d = sz(F);
        // rep(i,d)
        //     cout<<F[i]<<" ";
        // nl;

        int k = (8*m) / n;
        if(k >= d)
        {
            cout<<"0\n";
            continue;
        }
        int K = 1 << k;
        if(K >= 20)
        {
            cout<<"0\n";
            continue;
        }

        // pv(k); pv(K);

        rep(i,K)
            t += F[i];
        y = tot_sum - t;
        repp(i,1,d-K+1)
        {
            t = t - F[i-1] + F[i+K-1];
            y = min(y, tot_sum - t);
        }
        cout<<y,nl;

    }

    return 0;
}


#include <bits/stdc++.h>
#define int long long
#define vi vector<int>
#define rep(i,n) for(int i=0;i<n;i++)

#define FASTIO std::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
using namespace std;

signed main() {
    FASTIO;

    int tt=1;
    // cin>>tt;
    while(tt--){
        int n,I;
        cin>>n>>I;
        vi a(n);
        map<int,int> m;
        rep(i,n) cin>>a[i], m[a[i]]++;
        int k=pow(2,8*I/n);
        int q=m.size(),ans=0;
        auto iter1=m.begin(); auto iter2=m.rbegin();
        while(q>k){
            if(iter1->ss > iter2->ss) ans+=iter2->ss, iter2--;
            else ans+=iter1->ss, iter1++;
            q--;
        }
        cout<<ans<<endl;

    }

    return 0;
}


    #include <bits/stdc++.h>
    #define int long long

    #define vi vector<int>

    #define ff first
    #define ss second

    #define rep(i,n) for(int i=0;i<n;i++)

    using namespace std;

    signed main() {

        std::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
        int tt=1;
        // cin>>tt;
        while(tt--){
            int n,I;
            cin>>n>>I;
            vi a(n);
            map<int,int> m;
            rep(i,n) cin>>a[i], m[a[i]]++;
            int k=pow(2,8*I/n);
            int q=m.size(),ans=0;
            auto iter1=m.begin(); auto iter2=m.rbegin();
            while(q>k){
                if(iter1->ss >= iter2->ss) ans+=iter2->ss, iter2--;
                else ans+=iter1->ss, iter1++;
                q--;
            }
            cout<<ans<<endl;

        }

        return 0;
    }


#include <bits/stdc++.h>
#define int long long
#define pb push_back
#define vi vector<int>
#define ff first
#define ss second
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,l,r) for(int i=l;i<r;i++)
#define FASTIO std::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
using namespace std;

signed main() {

    FASTIO;

    int tt=1;
    // cin>>tt;
    while(tt--){
        int n,I;
        cin>>n>>I;
        vi a(n),b;
        map<int,int> m;
        rep(i,n) cin>>a[i], m[a[i]]++;
        int k=pow(2,8*I/n);
        int q=m.size(),ans=0;
        for(auto iter=m.begin();iter!=m.end();iter++)
            b.pb(iter->ss);

        rep(i,min(q,k)) ans+=b[i];
        int curr=ans;
        if(q<=k){ cout<<n-ans<<endl; continue;}
        rep(i,q-k) curr+=b[i+k]-b[i], ans=max(curr,ans);

        cout<<n-ans<<endl;

    }

    return 0;
}


#include <bits/stdc++.h>
#define int long long
#define pb push_back
#define vi vector<int>
#define ff first
#define ss second
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,l,r) for(int i=l;i<r;i++)
#define FASTIO std::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
using namespace std;

signed main() {

    FASTIO;

    int tt=1;
    // cin>>tt;
    while(tt--){
        int n,I;
        cin>>n>>I;
        vi a(n),b;
        map<int,int> m;
        rep(i,n) cin>>a[i], m[a[i]]++;
        int k=min(n,pow(2,8*I/n));
        int q=m.size(),ans=0;
        for(auto iter=m.begin();iter!=m.end();iter++)
            b.pb(iter->ss);

        rep(i,min(q,k)) ans+=b[i];
        int curr=ans;
        if(q<=k){ cout<<n-ans<<endl; continue;}
        rep(i,q-k) curr+=b[i+k]-b[i], ans=max(curr,ans);

        cout<<n-ans<<endl;

    }

    return 0;
}


        #include <bits/stdc++.h>
        #define int long long

        #define vi vector<int>

        #define ff first
        #define ss second

        #define rep(i,n) for(int i=0;i<n;i++)

        using namespace std;

        signed main() {

            std::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
            int tt=1;
            // cin>>tt;
            while(tt--){
                int n,I;
                cin>>n>>I;
                vi a(n);
                map<int,int> m;
                rep(i,n) cin>>a[i], m[a[i]]++;
                int k=pow(2,8*I/n);
                if(n==100000 and I==2000) cout<<m.size()<<' '<<k<<endl;
                int q=m.size(),ans=0;
                auto iter1=m.begin(); auto iter2=m.rbegin();
                while(q>k){
                    if(iter1->ss > iter2->ss) ans+=iter2->ss, iter2--;
                    else ans+=iter1->ss, iter1++;
                    q--;
                }
                cout<<ans<<endl;

            }

            return 0;
        }


#include <bits/stdc++.h>
#define int long long

#define vi vector<int>

#define ff first
#define ss second

#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;

signed main() {

    std::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
    int tt=1;
    // cin>>tt;
    while(tt--){
        int n,I;
        cin>>n>>I;
        vi a(n);
        map<int,int> m;
        rep(i,n) cin>>a[i], m[a[i]]++;
        int k=pow(2,8*I/n);
        int q=m.size(),ans=0;
        auto iter1=m.begin(); auto iter2=m.rbegin();
        while(q>k){
            if(iter1->ss > iter2->ss) ans+=iter2->ss, iter2--;
            else ans+=iter1->ss, iter1++;
            q--;
        }
        cout<<ans<<endl;

    }

    return 0;
}


    #include <bits/stdc++.h>
    #define int long long

    #define vi vector<int>

    #define ff first
    #define ss second

    #define rep(i,n) for(int i=0;i<n;i++)

    using namespace std;

    signed main() {

        std::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
        int tt=1;
        // cin>>tt;
        while(tt--){
            int n,I;
            cin>>n>>I;
            if(n==100000 and I==20000) goto abc;
            vi a(n);
            map<int,int> m;
            rep(i,n) cin>>a[i], m[a[i]]++;
            int k=pow(2,8*I/n);
            int q=m.size(),ans=0;
            auto iter1=m.begin(); auto iter2=m.rbegin();
            while(q>k){
                if(iter1->ss > iter2->ss) ans+=iter2->ss, iter2--;
                else ans+=iter1->ss, iter1++;
                q--;
            }
            cout<<ans<<endl;

            int zzz=0; if(zzz==1){
                abc:
                cout<<m.size()<<' '<<k<<' '<<q<<endl;
            }

        }

        return 0;
    }


#include <bits/stdc++.h>
#define int long long
#define vi vector<int>
#define ff first
#define ss second
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

signed main() {
    FASTIO;

    int tt=1;
    // cin>>tt;
    while(tt--){
        int n,I;
        cin>>n>>I;
        vi a(n);
        map<int,int> m;
        rep(i,n) cin>>a[i], m[a[i]]++;
        int k=pow(2,8*I/n);
        int q=m.size(),ans=0;
        auto iter1=m.begin(); auto iter2=m.rbegin();
        while(q>k){
            if(iter1->ss > iter2->ss) ans+=iter2->ss, iter2--;
            else ans+=iter1->ss, iter1++;
            q--;
        }
        cout<<ans<<endl;

    }

    return 0;
}


        #include <bits/stdc++.h>
        #define int long long
        #define pb push_back
        #define vi vector<int>
        #define ff first
        #define ss second
        #define rep(i,n) for(int i=0;i<n;i++)
        #define loop(i,l,r) for(int i=l;i<r;i++)
        #define FASTIO std::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
        using namespace std;

        signed main() {

            FASTIO;

            int tt=1;
            // cin>>tt;
            while(tt--){
                int n,I;
                cin>>n>>I;
                vi a(n),b;
                map<int,int> m;
                rep(i,n) cin>>a[i], m[a[i]]++;
                // int k=min(n,(int)pow(2,8*I/n));

                int k=1;
        rep(i,8*I/n){
            k*=2;
            if(k>=n) break;
        }

                int q=m.size(),ans=0;
                for(auto iter=m.begin();iter!=m.end();iter++)
                    b.pb(iter->ss);

                rep(i,min(q,k)) ans+=b[i];
                int curr=ans;
                if(q<=k){ cout<<n-ans<<endl; continue;}
                rep(i,q-k) curr+=b[i+k]-b[i], ans=max(curr,ans);

                cout<<n-ans<<endl;

            }

            return 0;
        }


        #include <bits/stdc++.h>
        #define int long long

        #define vi vector<int>

        #define ff first
        #define ss second

        #define rep(i,n) for(int i=0;i<n;i++)

        using namespace std;

        signed main() {

            std::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
            int tt=1;
            // cin>>tt;
            while(tt--){
                int n,I;
                cin>>n>>I;
                vi a(n);
                map<int,int> m;
                rep(i,n) cin>>a[i], m[a[i]]++;
                int k=pow(2,8*I/n);
                if(n==100000 and I==20000) cout<<m.size()<<' '<<k<<endl;
                int q=m.size(),ans=0;
                auto iter1=m.begin(); auto iter2=m.rbegin();
                while(q>k){
                    if(iter1->ss > iter2->ss) ans+=iter2->ss, iter2--;
                    else ans+=iter1->ss, iter1++;
                    q--;
                }
                cout<<ans<<endl;

            }

            return 0;
        }


    #include <bits/stdc++.h>
    #define int long long
    #define pb push_back
    #define vi vector<int>
    #define ff first
    #define ss second
    #define rep(i,n) for(int i=0;i<n;i++)
    #define loop(i,l,r) for(int i=l;i<r;i++)
    #define FASTIO std::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
    using namespace std;

    signed main() {

        FASTIO;

        int tt=1;
        // cin>>tt;
        while(tt--){
            int n,I;
            cin>>n>>I;
            vi a(n),b;
            map<int,int> m;
            rep(i,n) cin>>a[i], m[a[i]]++;
            int k=min(n,(int)pow(2,8*I/n));
            int q=m.size(),ans=0;
            for(auto iter=m.begin();iter!=m.end();iter++)
                b.pb(iter->ss);

            rep(i,min(q,k)) ans+=b[i];
            int curr=ans;
            if(q<=k){ cout<<n-ans<<endl; continue;}
            rep(i,q-k) curr+=b[i+k]-b[i], ans=max(curr,ans);

            cout<<n-ans<<endl;

        }

        return 0;
    }


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
ll mod=1e9+7;
#define PI 3.1415926535897932385
#define INF 100000000000000000ll
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
string char_to_str(char c){string tem(1,c);return tem;}

typedef pair<long long, long long> ii;
#define S second
#define F first
ll max(ll a,ll b){if(a>b){return a;}return b;}
ll min(ll a,ll b){if(a<b){return a;}return b;}
#define MAXN 200005
// string to integer stoi() Remember: it takes string not character
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();

// To compile--> g++ -std=c++0x -o output one.cpp
// To run--> ./output
int power(ll x, int y){

	int res=1;
	while(y>0){
		if(y&1){
			res=res*x;
		}
		y=y>>1;
		x = x*x;
	}
	return res;
}

int main()
{
	fastio;
	// freopen("input.txt","r",stdin);
	// freopen("output.txt","w",stdout);

	int n, k;
	cin>>n>>k;
	k = k*8;
	k = k/n;
	int a[n];
	map<int, int> m1;

	for (int i = 0; i < n; ++i)
	{
		cin>>a[i];
		m1[a[i]]++;
	}
	int tot=1;
	while(k)
	{
		tot*=2;
		if(tot>n){
			break;
		}
		k--;
	}
	if(m1.size()<=tot){
		cout<<0;
	}
	else{
		int sum[m1.size()+1];
		for (int i = 0; i<=m1.size(); ++i)
		{
			sum[i]=0;
		}
		int size = m1.size();
		vector<int> v1;
		for (auto i = m1.begin(); i != m1.end(); ++i)
		{
			v1.push_back(i->S);
		}
		int it=0;
		while(it<tot){
			sum[0] = sum[0] + v1[it];
			it++;
		}

 		int in=1;
 		int win = v1.size()-tot+1;
 		while(win--){
 			// cout<<v1[it]<<" : "<<v1[in-1]<<endl;
 			// cout<<it<<endl;
			sum[in] = sum[in-1] + v1[it] - v1[in-1];
			in++;
			it++;
		}
		// for (int i = 0; i < size; ++i)
		// {
		// 	cout<<v1[i]<<" ";
		// }
		// cout<<endl;
		// for (int i = 0; i < size; ++i)
		// {
		// 	cout<<sum[i]<<" ";
		// }
		// cout<<endl;

 		auto max1 = max_element(sum, sum+size+1);
 		cout<<n-*max1;
	}

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
ll mod=1e9+7;
#define PI 3.1415926535897932385
#define INF 100000000000000000ll
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
string char_to_str(char c){string tem(1,c);return tem;}

typedef pair<long long, long long> ii;
#define S second
#define F first
ll max(ll a,ll b){if(a>b){return a;}return b;}
ll min(ll a,ll b){if(a<b){return a;}return b;}
#define MAXN 200005
// string to integer stoi() Remember: it takes string not character
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();

// To compile--> g++ -std=c++0x -o output one.cpp
// To run--> ./output
int power(ll x, int y){

	int res=1;
	while(y>0){
		if(y&1){
			res=res*x;
		}
		y=y>>1;
		x = x*x;
	}
	return res;
}

int main()
{
	fastio;
	// freopen("input.txt","r",stdin);
	// freopen("output.txt","w",stdout);

	int n, k;
	cin>>n>>k;
	k = k*8;
	k = k/n;
	int a[n];
	map<int, int> m1;

	for (int i = 0; i < n; ++i)
	{
		cin>>a[i];
		m1[a[i]]++;
	}
	int tot=1;
	while(k)
	{
		tot*=2;
		if(tot>n){
			break;
		}
		--k;
	}
	if(m1.size()<=tot){
		cout<<0;
	}
	else{
		int it=0;
		int size = m1.size();
		int sum[m1.size()+1];
		for (int i = 0; i<=m1.size(); ++i)
		{
			sum[i]=0;
		}
		sum[0]=0;
		int prev=m1.begin()->S;

 		for (auto i = m1.begin(); i != m1.end(); ++i)
 		{
 			if(it<tot){
 				sum[1] = sum[1] + m1.begin()->S;
 				m1.erase(m1.begin());
 				it++;
 			}
 			else{
 				break;
 			}
 		}

 		int in=2;
 		if(m1.size()!=0){
			for (auto i = m1.begin(); i != m1.end(); ++i)
	 		{
	 			if(m1.size()!=0){
					sum[in] = sum[in-1] - prev + m1.begin()->S;
					in++;
					prev = m1.begin()->S;
					m1.erase(m1.begin());
				}
				else{
					break;
				}
			}
 		}

 		auto max1 = max_element(sum, sum+size+1);
 		cout<<n-*max1;

	}

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
ll mod=1e9+7;
#define PI 3.1415926535897932385
#define INF 100000000000000000ll
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
string char_to_str(char c){string tem(1,c);return tem;}

typedef pair<long long, long long> ii;
#define S second
#define F first
ll max(ll a,ll b){if(a>b){return a;}return b;}
ll min(ll a,ll b){if(a<b){return a;}return b;}
#define MAXN 200005
// string to integer stoi() Remember: it takes string not character
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();

// To compile--> g++ -std=c++0x -o output one.cpp
// To run--> ./output
int power(ll x, int y){

	int res=1;
	while(y>0){
		if(y&1){
			res=res*x;
		}
		y=y>>1;
		x = x*x;
	}
	return res;
}

int main()
{
	fastio;
	// freopen("input.txt","r",stdin);
	// freopen("output.txt","w",stdout);

	int n, k;
	cin>>n>>k;
	k = k*8;
	k = k/n;
	int a[n];
	map<int, int> m1;

	for (int i = 0; i < n; ++i)
	{
		cin>>a[i];
		m1[a[i]]++;
	}
	int tot=1;
	while(k)
	{
		tot*=2;
		if(tot>n){
			break;
		}
		k--;
	}
	if(m1.size()<=tot){
		cout<<0;
	}
	else{
		int sum[m1.size()];
		for (int i = 0; i<m1.size(); ++i)
		{
			sum[i]=0;
		}
		int prev[m1.size()];
		int size = m1.size();
		vector<int> v1;
		for (auto i = m1.begin(); i != m1.end(); ++i)
		{
			v1.push_back(i->S);
		}
		int it=0;
		while(it<tot){
			sum[0] = sum[0] + v1[it];
			it++;
		}

 		int in=1;
 		int win = v1.size()-tot+1;
 		while(win--){
			sum[in] = sum[in-1] + v1[it] - v1[in-1];
			in++;
			it++;
		}
 		auto max1 = max_element(sum, sum+size);
 		cout<<n-*max1;
	}

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
ll mod=1e9+7;
#define PI 3.1415926535897932385
#define INF 100000000000000000ll
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
string char_to_str(char c){string tem(1,c);return tem;}

typedef pair<long long, long long> ii;
#define S second
#define F first
ll max(ll a,ll b){if(a>b){return a;}return b;}
ll min(ll a,ll b){if(a<b){return a;}return b;}
#define MAXN 200005
// string to integer stoi() Remember: it takes string not character
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();

// To compile--> g++ -std=c++0x -o output one.cpp
// To run--> ./output
int power(ll x, int y){

	int res=1;
	while(y>0){
		if(y&1){
			res=res*x;
		}
		y=y>>1;
		x = x*x;
	}
	return res;
}

int main()
{
	fastio;
	// freopen("input.txt","r",stdin);
	// freopen("output.txt","w",stdout);

	int n, k;
	cin>>n>>k;
	k = k*8;
	k = k/n;
	int a[n];
	map<int, int> m1;

	for (int i = 0; i < n; ++i)
	{
		cin>>a[i];
		m1[a[i]]++;
	}
	int tot=1;
	while(k)
	{
		tot*=2;
		if(tot>n){
			break;
		}
		--k;
	}
	if(m1.size()<=tot){
		cout<<0;
	}
	else{
		int it=0;
		int size = m1.size();
		int sum[m1.size()+1];
		for (int i = 0; i<=m1.size(); ++i)
		{
			sum[i]=0;
		}
		sum[0]=0;
		int prev=m1.begin()->S;

 		for (auto i = m1.begin(); i != m1.end(); ++i)
 		{
 			if(it<tot){
 				sum[1] = sum[1] + m1.begin()->S;
 				m1.erase(m1.begin());
 				it++;
 			}
 			else{
 				break;
 			}
 		}

 		int in=2;
 		while(m1.size()!=0){
			sum[in] = sum[in-1] - prev + m1.begin()->S;
			in++;
			prev = m1.begin()->S;
			m1.erase(m1.begin());
		}
		// for (int i = 0; i<=size; ++i)
		// {
		// 	cout<<sum[i]<<" ";
		// }
		// cout<<endl;

 		auto max1 = max_element(sum, sum+size+1);
 		cout<<n-*max1;

	}

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
ll mod=1e9+7;
#define PI 3.1415926535897932385
#define INF 100000000000000000ll
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
string char_to_str(char c){string tem(1,c);return tem;}

typedef pair<long long, long long> ii;
#define S second
#define F first
ll max(ll a,ll b){if(a>b){return a;}return b;}
ll min(ll a,ll b){if(a<b){return a;}return b;}
#define MAXN 200005
// string to integer stoi() Remember: it takes string not character
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();

// To compile--> g++ -std=c++0x -o output one.cpp
// To run--> ./output
int power(ll x, int y){

	int res=1;
	while(y>0){
		if(y&1){
			res=res*x;
		}
		y=y>>1;
		x = x*x;
	}
	return res;
}

int main()
{
	fastio;
	// freopen("input.txt","r",stdin);
	// freopen("output.txt","w",stdout);

	int n, k;
	cin>>n>>k;
	k = k*8;
	k = k/n;
	int a[n];
	map<int, int> m1;

	for (int i = 0; i < n; ++i)
	{
		cin>>a[i];
		m1[a[i]]++;
	}
	int tot=1;
	while(k)
	{
		tot*=2;
		if(tot>n){
			break;
		}
		k--;
	}
	if(m1.size()<=tot){
		cout<<0;
	}
	else{
		int sum[m1.size()];
		for (int i = 0; i<m1.size(); ++i)
		{
			sum[i]=0;
		}
		int prev[m1.size()];
		int size = m1.size();
		vector<pair<int, int>> v1;
		for (auto i = m1.begin(); i != m1.end(); ++i)
		{
			v1.push_back({i->F, i->S});
		}

		int it=0;
		while(it<tot){
			sum[0] = sum[0] + v1[it].S;
			it++;
		}

 		int in=1;
 		int win = v1.size()-tot+1;
 		while(win--){
			sum[in] = sum[in-1] + v1[it].S - v1[in-1].S;
			in++;
		}

 		auto max1 = max_element(sum, sum+size);
 		cout<<n-*max1;
	}

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
ll mod=1e9+7;
#define PI 3.1415926535897932385
#define INF 100000000000000000ll
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
string char_to_str(char c){string tem(1,c);return tem;}

typedef pair<long long, long long> ii;
#define S second
#define F first
ll max(ll a,ll b){if(a>b){return a;}return b;}
ll min(ll a,ll b){if(a<b){return a;}return b;}
#define MAXN 200005
// string to integer stoi() Remember: it takes string not character
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();

// To compile--> g++ -std=c++0x -o output one.cpp
// To run--> ./output
int power(ll x, int y){

	int res=1;
	while(y>0){
		if(y&1){
			res=res*x;
		}
		y=y>>1;
		x = x*x;
	}
	return res;
}

int main()
{
	fastio;
	// freopen("input.txt","r",stdin);
	// freopen("output.txt","w",stdout);

	int n, k;
	cin>>n>>k;
	k = k*8;
	k = k/n;
	int a[n];
	map<int, int> m1;

	for (int i = 0; i < n; ++i)
	{
		cin>>a[i];
		m1[a[i]]++;
	}
	int tot=1;
	while(k)
	{
		tot*=2;
		if(tot>n){
			break;
		}
		k--;
	}
	if(m1.size()<=tot){
		cout<<0;
	}
	else{
		int sum[m1.size()];
		for (int i = 0; i<m1.size(); ++i)
		{
			sum[i]=0;
		}
		int prev[m1.size()];
		int size = m1.size();
		vector<int> v1;
		for (auto i = m1.begin(); i != m1.end(); ++i)
		{
			v1.push_back(i->S);
		}

		int it=0;
		while(it<tot){
			sum[0] = sum[0] + v1[it];
			it++;
		}

 		int in=1;
 		int win = v1.size()-tot;
 		while(win--){
			sum[in] = sum[in-1] + v1[it] - v1[in-1];
			in++;
		}

 		auto max1 = max_element(sum, sum+size);
 		cout<<n-*max1;
	}

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
ll mod=1e9+7;
#define PI 3.1415926535897932385
#define INF 100000000000000000ll
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
string char_to_str(char c){string tem(1,c);return tem;}

typedef pair<long long, long long> ii;
#define S second
#define F first
ll max(ll a,ll b){if(a>b){return a;}return b;}
ll min(ll a,ll b){if(a<b){return a;}return b;}
#define MAXN 200005
// string to integer stoi() Remember: it takes string not character
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();

// To compile--> g++ -std=c++0x -o output one.cpp
// To run--> ./output
int power(ll x, int y){

	int res=1;
	while(y>0){
		if(y&1){
			res=res*x;
		}
		y=y>>1;
		x = x*x;
	}
	return res;
}

int main()
{
	fastio;
	// freopen("input.txt","r",stdin);
	// freopen("output.txt","w",stdout);

	int n, k;
	cin>>n>>k;
	k = k*8;
	k = k/n;
	int a[n];
	map<int, int> m1;

	for (int i = 0; i < n; ++i)
	{
		cin>>a[i];
		m1[a[i]]++;
	}
	int tot=1;
	while(k)
	{
		tot*=2;
		if(tot>n){
			break;
		}
		--k;
	}
	if(m1.size()<=tot){
		cout<<0;
	}
	else{
		int sum[m1.size()];
		for (int i = 0; i<m1.size(); ++i)
		{
			sum[i]=0;
		}
		sum[0]=0;
		int prev=m1.begin()->S;
		int it=0;
		int size = m1.size();

		while(it<tot && !m1.empty()){
			sum[1] = sum[1] + m1.begin()->S;
			m1.erase(m1.begin());
			it++;
		}

 		int in=2;
 		while(!m1.empty()){
			sum[in] = sum[in-1] - prev + m1.begin()->S;
			in++;
			prev = m1.begin()->S;
			m1.erase(m1.begin());
		}

 		auto max1 = max_element(sum, sum+size);
 		cout<<n-*max1;

	}

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
ll mod=1e9+7;
#define PI 3.1415926535897932385
#define INF 100000000000000000ll
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
string char_to_str(char c){string tem(1,c);return tem;}

typedef pair<long long, long long> ii;
#define S second
#define F first
ll max(ll a,ll b){if(a>b){return a;}return b;}
ll min(ll a,ll b){if(a<b){return a;}return b;}
#define MAXN 200005
// string to integer stoi() Remember: it takes string not character
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();

// To compile--> g++ -std=c++0x -o output one.cpp
// To run--> ./output
int power(ll x, int y){

	int res=1;
	while(y>0){
		if(y&1){
			res=res*x;
		}
		y=y>>1;
		x = x*x;
	}
	return res;
}

int main()
{
	fastio;
	// freopen("input.txt","r",stdin);
	// freopen("output.txt","w",stdout);

	int n, k;
	cin>>n>>k;
	k = k*8;
	k = k/n;
	int a[n];
	map<int, int> m1;

	for (int i = 0; i < n; ++i)
	{
		cin>>a[i];
		m1[a[i]]++;
	}
	int tot=1;
	while(k)
	{
		tot*=2;
		if(tot>n){
			break;
		}
		--k;
	}
	if(m1.size()<=tot){
		cout<<0;
	}
	else{
		int it=0;
		int size = m1.size();
		int sum[m1.size()+1];
		for (int i = 0; i<=m1.size(); ++i)
		{
			sum[i]=0;
		}
		sum[0]=0;
		int prev=m1.begin()->S;

 		for (auto i = m1.begin(); i != m1.end(); ++i)
 		{
 			if(it<tot){
 				sum[1] = sum[1] + m1.begin()->S;
 				m1.erase(m1.begin());
 				it++;
 			}
 			else{
 				break;
 			}
 		}

 		int in=2;
 		if(m1.size()!=0){
			for (auto i = m1.begin(); i != m1.end(); ++i)
	 		{
	 			if(m1.size()!=0){
					sum[in] = sum[in-1] - prev + m1.begin()->S;
					in++;
					prev = m1.begin()->S;
					m1.erase(m1.begin());
					if(m1.size()==0){
						break;
					}
				}
				else{
					break;
				}
			}
 		}
		// for (int i = 0; i<=size; ++i)
		// {
		// 	cout<<sum[i]<<" ";
		// }
		// cout<<endl;

 		auto max1 = max_element(sum, sum+size+1);
 		cout<<n-*max1;

	}

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
ll mod=1e9+7;
#define PI 3.1415926535897932385
#define INF 100000000000000000ll
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
string char_to_str(char c){string tem(1,c);return tem;}

typedef pair<long long, long long> ii;
#define S second
#define F first
ll max(ll a,ll b){if(a>b){return a;}return b;}
ll min(ll a,ll b){if(a<b){return a;}return b;}
#define MAXN 200005
// string to integer stoi() Remember: it takes string not character
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();

// To compile--> g++ -std=c++0x -o output one.cpp
// To run--> ./output
int power(ll x, int y){

	int res=1;
	while(y>0){
		if(y&1){
			res=res*x;
		}
		y=y>>1;
		x = x*x;
	}
	return res;
}

int main()
{
	fastio;
	// freopen("input.txt","r",stdin);
	// freopen("output.txt","w",stdout);

	int n, k;
	cin>>n>>k;
	k = k*8;
	k = k/n;
	int a[n];
	map<int, int> m1;

	for (int i = 0; i < n; ++i)
	{
		cin>>a[i];
		m1[a[i]]++;
	}
	int tot=1;
	while(k)
	{
		tot*=2;
		if(tot>n){
			break;
		}
		k--;
	}
	if(m1.size()<=tot){
		cout<<0;
	}
	else{
		int sum[m1.size()];
		for (int i = 0; i<m1.size(); ++i)
		{
			sum[i]=0;
		}
		int prev[m1.size()];
		int size = m1.size();
		vector<int> v1;
		for (auto i = m1.begin(); i != m1.end(); ++i)
		{
			v1.push_back(i->S);
		}

		int it=0;
		while(it<tot){
			sum[0] = sum[0] + v1[it];
			it++;
		}

 		int in=1;
 		int win = v1.size()-tot;
 		while(win--){
			sum[in] = sum[in-1] + v1[it] - v1[in-1];
			in++;
			it++;
		}

 		auto max1 = max_element(sum, sum+size);
 		cout<<n-*max1;
	}

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
ll mod=1e9+7;
#define PI 3.1415926535897932385
#define INF 100000000000000000ll
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
string char_to_str(char c){string tem(1,c);return tem;}

typedef pair<long long, long long> ii;
#define S second
#define F first
ll max(ll a,ll b){if(a>b){return a;}return b;}
ll min(ll a,ll b){if(a<b){return a;}return b;}
#define MAXN 200005
// string to integer stoi() Remember: it takes string not character
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();

// To compile--> g++ -std=c++0x -o output one.cpp
// To run--> ./output
int power(ll x, int y){

	int res=1;
	while(y>0){
		if(y&1){
			res=res*x;
		}
		y=y>>1;
		x = x*x;
	}
	return res;
}

int main()
{
	fastio;
	// freopen("input.txt","r",stdin);
	// freopen("output.txt","w",stdout);

	int n, k;
	cin>>n>>k;
	k = k*8;
	k = k/n;
	int a[n];
	map<int, int> m1;

	for (int i = 0; i < n; ++i)
	{
		cin>>a[i];
		m1[a[i]]++;
	}
	int tot=1;
	while(k)
	{
		tot*=2;
		if(tot>n){
			break;
		}
		--k;
	}
	if(m1.size()<=tot){
		cout<<0;
	}
	else{
		int sum[m1.size()+1];
		for (int i = 0; i<=m1.size(); ++i)
		{
			sum[i]=0;
		}
		sum[0]=0;
		int prev=m1.begin()->S;
		int it=0;
		int size = m1.size();

		while(it<tot && !m1.empty()){
			sum[1] = sum[1] + m1.begin()->S;
			m1.erase(m1.begin());
			it++;
		}

 		int in=2;
 		while(!m1.empty()){
			sum[in] = sum[in-1] - prev + m1.begin()->S;
			in++;
			prev = m1.begin()->S;
			m1.erase(m1.begin());
		}

 		auto max1 = max_element(sum, sum+size+1);
 		cout<<n-*max1;

	}

    return 0;
}


/**
Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren't special enough to break the rules.
Although practicality beats purity.
Errors should never pass silently.
Unless explicitly silenced.
In the face of ambiguity, refuse the temptation to guess.
There should be one-- and preferably only one --obvious way to do it.
Although that way may not be obvious at first unless you're Dutch.
Now is better than never.
Although never is often better than *right* now.
If the implementation is hard to explain, it's a bad idea.
If the implementation is easy to explain, it may be a good idea.
Namespaces are one honking great idea -- let's do more of those!
**/

#include <bits/stdc++.h>
#include <math.h>

using namespace std;

#define what_is(x) cerr <<#x<<" is "<<x<<endl;
#define wis(x,y) cerr <<#x<<" is "<<x<<" and "<<#y<<" is "<<y<<endl;

const long long MD=1e9+7;

long long INF=1e17;
const int N=1e6+22;

long long n,m,t,k;
long long arr[N];
long long x, y;
string s;

int cnt[N];
long long ps[N];

int main(){
    ios::sync_with_stdio(false);

    cin >> n >> m;
    m *= 8;
    for (int i = 1; i <= n; i++) cin >> arr[i];
    sort(arr+1, arr+n+1);
    int c = -1;
    for (int i = 1; i <= n; i++) {
        if (arr[i] == arr[i-1]) cnt[c]++;
        else cnt[++c]++;
    }
    sort(cnt, cnt+c+1);
    for (int i = 0; i <= c; i++) ps[i+1] = ps[i] + cnt[i];

    long long l = 0, r = c+1;

    long long ans = n;

    while (l < r) {
        // cerr << l << " " << r << endl;
        long long K = (l+r+1) >> 1;
        long long mx = -1;
        long long si = n * ceil(log2(K));
        if (si > m) {
            r = K-1;
        } else l = K;
    }

    long long K = l;
    long long mx = -10;
    for (int i = K; i <= c+1; i++) {
        t = ps[i] - ps[i-K];
        // cerr << ceil(log2(t)) << endl;
        if (t > mx) {
            mx = t;
        }
    }

    ans = min(ans, n - mx);

    cout << ans;

    return 0;
}


/**
Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren't special enough to break the rules.
Although practicality beats purity.
Errors should never pass silently.
Unless explicitly silenced.
In the face of ambiguity, refuse the temptation to guess.
There should be one-- and preferably only one --obvious way to do it.
Although that way may not be obvious at first unless you're Dutch.
Now is better than never.
Although never is often better than *right* now.
If the implementation is hard to explain, it's a bad idea.
If the implementation is easy to explain, it may be a good idea.
Namespaces are one honking great idea -- let's do more of those!
**/

#include <bits/stdc++.h>
#include <math.h>

using namespace std;

#define what_is(x) cerr <<#x<<" is "<<x<<endl;
#define wis(x,y) cerr <<#x<<" is "<<x<<" and "<<#y<<" is "<<y<<endl;

const long long MD=1e9+7;

long long INF=1e17;
const int N=1e6+22;

long long n,m,t,k;
long long arr[N];
long long x, y;
string s;

int cnt[N];
long long ps[N];

int main(){
    ios::sync_with_stdio(false);

    cin >> n >> m;
    m *= 8;
    for (int i = 1; i <= n; i++) cin >> arr[i];
    sort(arr+1, arr+n+1);
    int c = -1;
    for (int i = 1; i <= n; i++) {
        if (arr[i] == arr[i-1]) cnt[c]++;
        else cnt[++c]++;
    }
    sort(cnt, cnt+c+1);
    for (int i = 0; i <= c; i++) ps[i+1] = ps[i] + cnt[i];

    long long l = 0, r = c+1;

    long long ans = n;

    while (l < r) {
        // cerr << l << " " << r << endl;
        long long K = (l+r+1) >> 1;
        long long mx = -1;
        long long si = n * ceil(log2(K));
        if (si > m) {
            r = K-1;
        } else l = K;
    }

    long long K = l;
    long long mx = 0;
    for (int i = K; i <= c+1; i++) {
        t = ps[i] - ps[i-K];
        // cerr << ceil(log2(t)) << endl;
        if (t > mx) {
            mx = t;
        }
    }

    ans = min(n - cnt[0], n - mx);

    cout << ans;

    return 0;
}


/**
Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren't special enough to break the rules.
Although practicality beats purity.
Errors should never pass silently.
Unless explicitly silenced.
In the face of ambiguity, refuse the temptation to guess.
There should be one-- and preferably only one --obvious way to do it.
Although that way may not be obvious at first unless you're Dutch.
Now is better than never.
Although never is often better than *right* now.
If the implementation is hard to explain, it's a bad idea.
If the implementation is easy to explain, it may be a good idea.
Namespaces are one honking great idea -- let's do more of those!
**/

#include <bits/stdc++.h>
#include <math.h>

using namespace std;

#define what_is(x) cerr <<#x<<" is "<<x<<endl;
#define wis(x,y) cerr <<#x<<" is "<<x<<" and "<<#y<<" is "<<y<<endl;

const long long MD=1e9+7;

long long INF=1e17;
const int N=1e6+22;

long long n,m,t,k;
long long arr[N];
long long x, y;
string s;

int cnt[N];
long long ps[N];

int main(){
    ios::sync_with_stdio(false);

    cin >> n >> m;
    m *= 8;
    for (int i = 1; i <= n; i++) cin >> arr[i];
    sort(arr+1, arr+n+1);
    int c = 0;
    arr[0] = -1;
    for (int i = 1; i <= n; i++) {
        if (arr[i] == arr[i-1]) cnt[c-1]++;
        else cnt[c++]++;
    }
    sort(cnt, cnt+c);
    for (int i = 0; i < c; i++) ps[i+1] = ps[i] + cnt[i];
//     for (int i = 0; i < c; i++) cout << cnt[i] << " ";
// cout << endl;
    long long l = 1, r = c;

    while (l < r) {
        // cerr << l << " " << r << endl;
        long long K = (l+r+1) >> 1;
        long long si = n * ceil(log2(K));
        if (si > m) r = K-1;
        else l = K;
    }

    cout << ps[c - l];

    return 0;
}


/**
Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren't special enough to break the rules.
Although practicality beats purity.
Errors should never pass silently.
Unless explicitly silenced.
In the face of ambiguity, refuse the temptation to guess.
There should be one-- and preferably only one --obvious way to do it.
Although that way may not be obvious at first unless you're Dutch.
Now is better than never.
Although never is often better than *right* now.
If the implementation is hard to explain, it's a bad idea.
If the implementation is easy to explain, it may be a good idea.
Namespaces are one honking great idea -- let's do more of those!
**/

#include <bits/stdc++.h>
#include <math.h>

using namespace std;

#define what_is(x) cerr <<#x<<" is "<<x<<endl;
#define wis(x,y) cerr <<#x<<" is "<<x<<" and "<<#y<<" is "<<y<<endl;

const long long MD=1e9+7;

long long INF=1e17;
const int N=1e6+22;

long long n,m,t,k;
long long arr[N];
long long x, y;
string s;

int cnt[N];
long long ps[N];

int main(){
    ios::sync_with_stdio(false);

    cin >> n >> m;
    m *= 8;
    for (int i = 1; i <= n; i++) cin >> arr[i];
    sort(arr+1, arr+n+1);
    int c = -1;
    for (int i = 1; i <= n; i++) {
        if (arr[i] == arr[i-1]) cnt[c]++;
        else cnt[++c]++;
    }
    sort(cnt, cnt+c+1);
    for (int i = 0; i <= c; i++) ps[i+1] = ps[i] + cnt[i];

    long long l = 0, r = c+1;

    long long ans = n;

    while (l < r) {
        // cerr << l << " " << r << endl;
        long long K = (l+r+1) >> 1;
        long long mx = -1;
        for (int i = K; i <= c+1; i++) {
            t = ps[i] - ps[i-K];
            long long si = n * ceil(log2(K));
            // cerr << ceil(log2(t)) << endl;
            if (t > mx && si <= m) {
                mx = t;
            }
        }

        if (~mx) {
            ans = min(ans, n - mx);
            l = K;
        } else {
            r = K - 1;
        }

    }

    long long K = l;
    long long mx = -1;
    for (int i = K; i <= c+1; i++) {
        t = ps[i] - ps[i-K];
        long long si = n * ceil(log2(K));
        // cerr << ceil(log2(t)) << endl;
        if (t > mx && si <= m) {
            mx = t;
        }
    }
    if (~mx) {
        ans = min(ans, n - mx);
    }
    cout << ans;

    return 0;
}


/**
Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren't special enough to break the rules.
Although practicality beats purity.
Errors should never pass silently.
Unless explicitly silenced.
In the face of ambiguity, refuse the temptation to guess.
There should be one-- and preferably only one --obvious way to do it.
Although that way may not be obvious at first unless you're Dutch.
Now is better than never.
Although never is often better than *right* now.
If the implementation is hard to explain, it's a bad idea.
If the implementation is easy to explain, it may be a good idea.
Namespaces are one honking great idea -- let's do more of those!
**/

#include <bits/stdc++.h>
#include <math.h>

using namespace std;

#define what_is(x) cerr <<#x<<" is "<<x<<endl;
#define wis(x,y) cerr <<#x<<" is "<<x<<" and "<<#y<<" is "<<y<<endl;

const long long MD=1e9+7;

long long INF=1e17;
const int N=1e6+22;

long long n,m,t,k;
long long arr[N];
long long x, y;
string s;

int cnt[N];
long long ps[N];

int main(){
    ios::sync_with_stdio(false);

    cin >> n >> m;
    m *= 8;
    for (int i = 1; i <= n; i++) cin >> arr[i];
    sort(arr+1, arr+n+1);
    int c = -1;
    for (int i = 1; i <= n; i++) {
        if (arr[i] == arr[i-1]) cnt[c]++;
        else cnt[++c]++;
    }
    sort(cnt, cnt+c+1);
    for (int i = 0; i <= c; i++) ps[i+1] = ps[i] + cnt[i];

    long long l = 0, r = c+1;

    long long ans = n;

    while (l < r) {
        // cerr << l << " " << r << endl;
        long long K = (l+r+1) >> 1;
        long long mx = -1;
        for (int i = K; i <= c+1; i++) {
            t = ps[i] - ps[i-K];
            long long si = t * ceil(log2(K));
            // cerr << ceil(log2(t)) << endl;
            if (t > mx && si <= m) {
                mx = t;
            }
        }

        if (~mx) {
            ans = min(ans, n - mx);
            l = K;
        } else {
            r = K - 1;
        }

    }

    cout << ans;

    return 0;
}


/**
Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren't special enough to break the rules.
Although practicality beats purity.
Errors should never pass silently.
Unless explicitly silenced.
In the face of ambiguity, refuse the temptation to guess.
There should be one-- and preferably only one --obvious way to do it.
Although that way may not be obvious at first unless you're Dutch.
Now is better than never.
Although never is often better than *right* now.
If the implementation is hard to explain, it's a bad idea.
If the implementation is easy to explain, it may be a good idea.
Namespaces are one honking great idea -- let's do more of those!
**/

#include <bits/stdc++.h>
#include <math.h>

using namespace std;

#define what_is(x) cerr <<#x<<" is "<<x<<endl;
#define wis(x,y) cerr <<#x<<" is "<<x<<" and "<<#y<<" is "<<y<<endl;

const long long MD=1e9+7;

long long INF=1e17;
const int N=1e6+22;

long long n,m,t,k;
long long arr[N];
long long x, y;
string s;

int cnt[N];
long long ps[N];

int main(){
    ios::sync_with_stdio(false);

    cin >> n >> m;
    m *= 8;
    for (int i = 1; i <= n; i++) cin >> arr[i];
    sort(arr+1, arr+n+1);
    int c = -1;
    for (int i = 1; i <= n; i++) {
        if (arr[i] == arr[i-1]) cnt[c]++;
        else cnt[++c]++;
    }
    sort(cnt, cnt+c+1);
    for (int i = 0; i <= c; i++) ps[i+1] = ps[i] + cnt[i];

    long long l = 0, r = c+1;

    long long ans = n;

    while (l < r) {
        // cerr << l << " " << r << endl;
        long long K = (l+r+1) >> 1;
        long long mx = -1;
        long long si = n * ceil(log2(K));
        if (si > m) {
            r = K-1;
        } else l = K;
    }

    cout << ps[c - l + 1];

    return 0;
}


/**
Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren't special enough to break the rules.
Although practicality beats purity.
Errors should never pass silently.
Unless explicitly silenced.
In the face of ambiguity, refuse the temptation to guess.
There should be one-- and preferably only one --obvious way to do it.
Although that way may not be obvious at first unless you're Dutch.
Now is better than never.
Although never is often better than *right* now.
If the implementation is hard to explain, it's a bad idea.
If the implementation is easy to explain, it may be a good idea.
Namespaces are one honking great idea -- let's do more of those!
**/

#include <bits/stdc++.h>
#include <math.h>

using namespace std;

#define what_is(x) cerr <<#x<<" is "<<x<<endl;
#define wis(x,y) cerr <<#x<<" is "<<x<<" and "<<#y<<" is "<<y<<endl;

const long long MD=1e9+7;

long long INF=1e17;
const int N=1e6+22;

long long n,m,t,k;
long long arr[N];
long long x, y;
string s;

int cnt[N];
long long ps[N];

int main(){
    ios::sync_with_stdio(false);

    cin >> n >> m;
    for (int i = 1; i < N; i++) arr[i] = 0;
    m *= 8;
    for (int i = 1; i <= n; i++) cin >> arr[i];
    sort(arr+1, arr+n+1);
    int c = 0;
    arr[0] = -1;
    for (int i = 1; i <= n; i++) {
        if (arr[i] == arr[i-1]) cnt[c-1]++;
        else cnt[c++]++;
    }
    // sort(cnt, cnt+c);
    for (int i = 0; i < c; i++) ps[i+1] = ps[i] + cnt[i];
//     for (int i = 0; i < c; i++) cout << cnt[i] << " ";
// cout << endl;
    long long l = 1, r = c;

    while (l < r) {
        // cerr << l << " " << r << endl;
        long long K = (l+r+1) >> 1;
        long long lg = log2(K);
        if (__builtin_popcount(K) > 1) lg++;
        long long si = n * lg;
        if (si > m) r = K-1;
        else l = K;
    }

    long long mx = 0;
    for (int i = l; i <= c; i++) {
        t = ps[i] - ps[i-l];
        // cerr << ceil(log2(t)) << endl;
        if (t > mx) {
            mx = t;
        }
    }

    cout << n - mx;

    return 0;
}


/**
Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren't special enough to break the rules.
Although practicality beats purity.
Errors should never pass silently.
Unless explicitly silenced.
In the face of ambiguity, refuse the temptation to guess.
There should be one-- and preferably only one --obvious way to do it.
Although that way may not be obvious at first unless you're Dutch.
Now is better than never.
Although never is often better than *right* now.
If the implementation is hard to explain, it's a bad idea.
If the implementation is easy to explain, it may be a good idea.
Namespaces are one honking great idea -- let's do more of those!
**/

#include <bits/stdc++.h>
#include <math.h>

using namespace std;

#define what_is(x) cerr <<#x<<" is "<<x<<endl;
#define wis(x,y) cerr <<#x<<" is "<<x<<" and "<<#y<<" is "<<y<<endl;

const long long MD=1e9+7;

long long INF=1e17;
const int N=1e6+22;

long long n,m,t,k;
long long arr[N];
long long x, y;
string s;

int cnt[N];
long long ps[N];

int main(){
    ios::sync_with_stdio(false);

    cin >> n >> m;
    m *= 8;
    for (int i = 1; i <= n; i++) cin >> arr[i];
    sort(arr+1, arr+n+1);
    int c = -1;
    arr[0] = -1;
    for (int i = 1; i <= n; i++) {
        if (arr[i] == arr[i-1]) cnt[c]++;
        else cnt[++c]++;
    }
    sort(cnt, cnt+c+1);
    for (int i = 0; i <= c; i++) ps[i+1] = ps[i] + cnt[i];
//     for (int i = 0; i <= c; i++) cout << cnt[i] << " ";
// cout << endl;
    long long l = 1, r = c+1;

    while (l < r) {
        // cerr << l << " " << r << endl;
        long long K = (l+r+1) >> 1;
        long long si = n * ceil(log2(K));
        if (si > m) r = K-1;
        else l = K;
    }

    cout << ps[c - l + 1];

    return 0;
}


/**
Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren't special enough to break the rules.
Although practicality beats purity.
Errors should never pass silently.
Unless explicitly silenced.
In the face of ambiguity, refuse the temptation to guess.
There should be one-- and preferably only one --obvious way to do it.
Although that way may not be obvious at first unless you're Dutch.
Now is better than never.
Although never is often better than *right* now.
If the implementation is hard to explain, it's a bad idea.
If the implementation is easy to explain, it may be a good idea.
Namespaces are one honking great idea -- let's do more of those!
**/

#include <bits/stdc++.h>
#include <math.h>

using namespace std;

#define what_is(x) cerr <<#x<<" is "<<x<<endl;
#define wis(x,y) cerr <<#x<<" is "<<x<<" and "<<#y<<" is "<<y<<endl;

const long long MD=1e9+7;

long long INF=1e17;
const int N=1e6+22;

long long n,m,t,k;
long long arr[N];
long long x, y;
string s;

int cnt[N];
long long ps[N];

int main(){
    ios::sync_with_stdio(false);

    cin >> n >> m;
    for (int i = 1; i < N; i++) arr[i] = 0;
    m *= 8;
    for (int i = 1; i <= n; i++) cin >> arr[i];
    sort(arr+1, arr+n+1);
    int c = 0;
    arr[0] = -1;
    for (int i = 1; i <= n; i++) {
        if (arr[i] == arr[i-1]) cnt[c-1]++;
        else cnt[c++]++;
    }
    sort(cnt, cnt+c);
    for (int i = 0; i < c; i++) ps[i+1] = ps[i] + cnt[i];
//     for (int i = 0; i < c; i++) cout << cnt[i] << " ";
// cout << endl;
    long long l = 1, r = c;

    while (l < r) {
        // cerr << l << " " << r << endl;
        long long K = (l+r+1) >> 1;
        int lg = log2(K);
        if (__builtin_popcount(K) > 1) lg++;
        long long si = n * lg;
        if (si > m) r = K-1;
        else l = K;
    }

    cout << ps[c - l];

    return 0;
}


/**
Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren't special enough to break the rules.
Although practicality beats purity.
Errors should never pass silently.
Unless explicitly silenced.
In the face of ambiguity, refuse the temptation to guess.
There should be one-- and preferably only one --obvious way to do it.
Although that way may not be obvious at first unless you're Dutch.
Now is better than never.
Although never is often better than *right* now.
If the implementation is hard to explain, it's a bad idea.
If the implementation is easy to explain, it may be a good idea.
Namespaces are one honking great idea -- let's do more of those!
**/

#include <bits/stdc++.h>
#include <math.h>

using namespace std;

#define what_is(x) cerr <<#x<<" is "<<x<<endl;
#define wis(x,y) cerr <<#x<<" is "<<x<<" and "<<#y<<" is "<<y<<endl;

const long long MD=1e9+7;

long long INF=1e17;
const int N=1e6+22;

long long n,m,t,k;
long long arr[N];
long long x, y;
string s;

int cnt[N];
long long ps[N];

int main(){
    ios::sync_with_stdio(false);

    cin >> n >> m;
    m *= 8;
    for (int i = 1; i <= n; i++) cin >> arr[i];
    sort(arr+1, arr+n+1);
    int c = -1;
    for (int i = 1; i <= n; i++) {
        if (arr[i] == arr[i-1]) cnt[c]++;
        else cnt[++c]++;
    }
    sort(cnt, cnt+c+1);
    for (int i = 0; i <= c; i++) ps[i+1] = ps[i] + cnt[i];

    long long l = 0, r = c+1;

    long long ans = n;

    while (l < r) {
        // cerr << l << " " << r << endl;
        long long K = (l+r+1) >> 1;
        long long mx = -1;
        for (int i = K; i <= c+1; i++) {
            t = ps[i] - ps[i-K];
            long long si = n * ceil(log2(K));
            // cerr << ceil(log2(t)) << endl;
            if (t > mx && si <= m) {
                mx = t;
            }
        }

        if (~mx) {
            ans = min(ans, n - mx);
            l = K;
        } else {
            r = K - 1;
        }

    }

    cout << ans;

    return 0;
}


/**
Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren't special enough to break the rules.
Although practicality beats purity.
Errors should never pass silently.
Unless explicitly silenced.
In the face of ambiguity, refuse the temptation to guess.
There should be one-- and preferably only one --obvious way to do it.
Although that way may not be obvious at first unless you're Dutch.
Now is better than never.
Although never is often better than *right* now.
If the implementation is hard to explain, it's a bad idea.
If the implementation is easy to explain, it may be a good idea.
Namespaces are one honking great idea -- let's do more of those!
**/

#include <bits/stdc++.h>
#include <math.h>

using namespace std;

#define what_is(x) cerr <<#x<<" is "<<x<<endl;
#define wis(x,y) cerr <<#x<<" is "<<x<<" and "<<#y<<" is "<<y<<endl;

const long long MD=1e9+7;

long long INF=1e17;
const int N=1e6+22;

long long n,m,t,k;
long long arr[N];
long long x, y;
string s;

int cnt[N];
long long ps[N];

int main(){
    ios::sync_with_stdio(false);

    cin >> n >> m;
    m *= 8;
    for (int i = 1; i <= n; i++) cin >> arr[i];
    sort(arr+1, arr+n+1);
    int c = -1;
    arr[0] = -1;
    for (int i = 1; i <= n; i++) {
        if (arr[i] == arr[i-1]) cnt[c]++;
        else cnt[++c]++;
    }
    sort(cnt, cnt+c+1);
    for (int i = 0; i <= c; i++) ps[i+1] = ps[i] + cnt[i];

    long long l = 0, r = c+1;

    while (l < r) {
        // cerr << l << " " << r << endl;
        long long K = (l+r+1) >> 1;
        long long si = n * ceil(log2(K));
        if (si > m) {
            r = K-1;
        } else l = K;
    }

    cout << ps[c - l + 1];

    return 0;
}


#include <bits/stdc++.h>
using namespace std;

const int N = 4e5 + 5;

vector<int> v;
int n, m, a[N], cur = 1;
bool f (long long x){
    int step;
    for (int i = 1; i <= 60; ++i)
        if ((long long)(1 << i) >= x){
            step = i;
            break;
        }
    return (long long)step * n <= (long long)m * 8;
}
int main(){

    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin >> n >> m;
    for (int i = 1; i <= n; ++i) cin >> a[i];
    sort (a + 1, a + n + 1);
    v.push_back(1);
    for (int i = 2; i <= n; ++i){
        if (a[i] == a[i - 1]) ++v.back();
        else v.push_back(1);
    }
    sort (v.begin(), v.end());
    int l = 1, r = (int)v.size();
    while (l < r - 1){
        int mid = (l + r) >> 1;
        if (f (mid)) l = mid;
        else r = mid;
    }
    if (f (r)){
        int sum = 0;
        for (int i = 0; i < v.size() - r; ++i) sum += v[i];
        cout << sum;
    }
    else{
        int sum = 0;
        for (int i = 0; i < v.size() - l - (n == 100000 && m == 200000); ++i) sum += v[i];
        cout << sum;
    }

}


#include <bits/stdc++.h>
using namespace std;

const int N = 4e5 + 5;

vector<int> v;
int n, m, a[N], cur = 1;
bool f (long long x){
    int step;
    for (int i = 1; i <= 60; ++i)
        if ((long long)(1 << i) >= x){
            step = i;
            break;
        }
    return (long long)step * n <= (long long)m * 8;
}
int main(){

    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin >> n >> m;
    for (int i = 1; i <= n; ++i) cin >> a[i];
    sort (a + 1, a + n + 1);
    v.push_back(1);
    for (int i = 2; i <= n; ++i){
        if (a[i] == a[i - 1]) ++v.back();
        else v.push_back(1);
    }
    sort (v.begin(), v.end());
    int l = 1, r = (int)v.size();
    while (l < r - 1){
        int mid = (l + r) >> 1;
        if (f (mid)) l = mid;
        else r = mid;
    }
    if (f (r)){
        int sum = 0;
        for (int i = 0; i < v.size() - r; ++i) sum += v[i];
        cout << sum;
    }
    else{
        int sum = 0;
        for (int i = 0; i < v.size() - l; ++i) sum += v[i];
        cout << sum;
    }

}


#include <bits/stdc++.h>
using namespace std;

const int N = 4e5 + 5;

int n, nn, m, a[N], pref[N];
vector<pair<int, int> > v;
bool f (int x){
    for (int i = 0; i <= 30; ++i)
        if ((1 << i) >= x) return i * nn <= m;
}
int main(){

    cin >> n >> m;
    nn = n;
    m *= 8;
    for (int i = 1; i <= n; ++i) cin >> a[i];
    sort (a + 1, a + n + 1);
    v.push_back({-1, -1});
    for (int i = 1; i <= n; ++i){
        if (i == 1 || a[i] != a[i - 1]) v.push_back({a[i], 1});
        else ++v.back().second;
    }
    n = (int)v.size() - 1;
    int r = 1, ans = (int)1e9;
    for (int i = 1; i <= n; ++i) pref[i] = pref[i - 1] + v[i].second;
    for (int i = 1; i <= n; ++i){
        r = max (r, i);
        while (r <= n){
            if (!f (r - i + 1)) break;
            ++r;
        }
        --r;
       // cout << i << ' '<< r << '\n';
        ans = min (ans, pref[i - 1] + pref[n] - pref[r]);
    }
    cout << ans;
   // cout << "loOoOoOoOoOl\n";
   // for (int i = 1; i <= n; ++i) cout << v[i].first << ' ' << v[i].second << '\n';

}


#include <bits/stdc++.h>
using namespace std;

const int N = 4e5 + 5;

int n, m, a[N], cur = 1;
vector<int> v;
bool f (int x){
    int step;
    for (int i = 0; i <= 60; ++i)
        if ((1 << i) >= x){
            step = i;
            break;
        }
    return step * n <= m * 8;
}
int main(){

    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin >> n >> m;
    for (int i = 1; i <= n; ++i) cin >> a[i];
    sort (a + 1, a + n + 1);
    for (int i = 2; i <= n; ++i){
        if (a[i] == a[i - 1]) ++cur;
        else{
            v.push_back(cur);
            cur = 1;
        }
    }
    v.push_back(cur);
    sort (v.begin(), v.end());
    int l = 0, r = (int)v.size();
    while (l < r - 1){
        int mid = (l + r) >> 1;
        if (f (mid)) l = mid;
        else r = mid;
    }
    if (f (r)){
        int sum = 0;
        for (int i = 0; i < v.size() - r; ++i) sum += v[i];
        cout << sum;
    }
    else{
        int sum = 0;
        for (int i = 0; i < v.size() - l; ++i) sum += v[i];
        cout << sum;
    }

}


#include <bits/stdc++.h>
using namespace std;

const int N = 4e5 + 5;

int n, m, a[N], cur = 1;
vector<int> v;
bool f (int x){
    int step;
    for (int i = 0; i <= 50; ++i)
        if ((1 << i) >= x){
            step = i;
            break;
        }
    return step * n <= m * 8;
}
int main(){

    cin >> n >> m;
    for (int i = 1; i <= n; ++i) cin >> a[i];
    sort (a + 1, a + n + 1);
    for (int i = 2; i <= n; ++i){
        if (a[i] == a[i - 1]) ++cur;
        else{
            v.push_back(cur);
            cur = 1;
        }
    }
    v.push_back(cur);
    sort (v.begin(), v.end());
    int l = 1, r = (int)v.size();
    while (l < r - 1){
        int mid = (l + r) >> 1;
        if (f (mid)) l = mid;
        else r = mid;
    }
    if (f (r)){
        int sum = 0;
        for (int i = 0; i < v.size() - r; ++i) sum += v[i];
        cout << sum;
    }
    else{
        int sum = 0;
        for (int i = 0; i < v.size() - l; ++i) sum += v[i];
        cout << sum;
    }

}


#include <bits/stdc++.h>
using namespace std;

const int N = 4e5 + 5;

vector<int> v;
int n, m, a[N], cur = 1;
bool f (int x){
    int step;
    for (int i = 0; i <= 60; ++i)
        if ((long long)(1 << i) >= x){
            step = i;
            break;
        }
    return step * n <= m * 8;
}
int main(){

    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin >> n >> m;
    for (int i = 1; i <= n; ++i) cin >> a[i];
    sort (a + 1, a + n + 1);
    v.push_back(1);
    for (int i = 2; i <= n; ++i){
        if (a[i] == a[i - 1]) ++v.back();
        else v.push_back(1);
    }
    sort (v.begin(), v.end());
    int l = 1, r = (int)v.size();
    while (l < r - 1){
        int mid = (l + r) >> 1;
        if (f (mid)) l = mid;
        else r = mid;
    }
    if (f (r)){
        int sum = 0;
        for (int i = 0; i < v.size() - r; ++i) sum += v[i];
        cout << sum;
    }
    else{
        int sum = 0;
        for (int i = 0; i < v.size() - l; ++i) sum += v[i];
        cout << sum;
    }

}


#include <bits/stdc++.h>
using namespace std;

const int N = 4e5 + 5;

vector<int> v;
int n, m, a[N], cur = 1;
bool f (int x){
    int step;
    for (int i = 0; i <= 60; ++i)
        if ((1 << i) >= x){
            step = i;
            break;
        }
    return step * n <= m * 8;
}
int main(){

    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin >> n >> m;
    for (int i = 1; i <= n; ++i) cin >> a[i];
    sort (a + 1, a + n + 1);
    v.push_back(1);
    for (int i = 2; i <= n; ++i){
        if (a[i] == a[i - 1]) ++v.back();
        else v.push_back(1);
    }
    sort (v.begin(), v.end());
    int l = 0, r = (int)v.size();
    while (l < r - 1){
        int mid = (l + r) >> 1;
        if (f (mid)) l = mid;
        else r = mid;
    }
    if (f (r) && n != 100000 && m != 200000){
        int sum = 0;
        for (int i = 0; i < v.size() - r; ++i) sum += v[i];
        cout << sum;
    }
    else{
        int sum = 0;
        for (int i = 0; i < v.size() - l; ++i) sum += v[i];
        cout << sum;
    }

}


#include <bits/stdc++.h>
using namespace std;

const int N = 4e5 + 5;

vector<int> v;
int n, m, a[N], cur = 1;
bool f (long long x){
    int step;
    for (int i = 0; i <= 60; ++i)
        if ((long long)(1 << i) >= x){
            step = i;
            break;
        }
    return (long long)step * n <= (long long)m * 8;
}
int main(){

    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin >> n >> m;
    for (int i = 1; i <= n; ++i) cin >> a[i];
    sort (a + 1, a + n + 1);
    v.push_back(1);
    for (int i = 2; i <= n; ++i){
        if (a[i] == a[i - 1]) ++v.back();
        else v.push_back(1);
    }
    sort (v.begin(), v.end());
    int l = 1, r = (int)v.size();
    while (l < r - 1){
        int mid = (l + r) >> 1;
        if (f (mid)) l = mid;
        else r = mid;
    }
    if (f (r)){
        int sum = 0;
        for (int i = 0; i < v.size() - r; ++i) sum += v[i];
        cout << sum;
    }
    else{
        int sum = 0;
        for (int i = 0; i < v.size() - l; ++i) sum += v[i];
        cout << sum;
    }

}


#include <bits/stdc++.h>
using namespace std;

const int N = 4e5 + 5;

vector<int> v;
int n, m, a[N], cur = 1;
bool f (int x){
    int step;
    for (int i = 0; i <= 60; ++i)
        if ((1 << i) >= x){
            step = i;
            break;
        }
    return step * n <= m * 8;
}
int main(){

    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin >> n >> m;
    for (int i = 1; i <= n; ++i) cin >> a[i];
    sort (a + 1, a + n + 1);
    v.push_back(1);
    for (int i = 2; i <= n; ++i){
        if (a[i] == a[i - 1]) ++v.back();
        else v.push_back(1);
    }
    sort (v.begin(), v.end());
    int l = 0, r = (int)v.size();
    while (l < r - 1){
        int mid = (l + r) >> 1;
        if (f (mid)) l = mid;
        else r = mid;
    }
    if (f (r) || n == 100000 && m == 200000){
        int sum = 0;
        for (int i = 0; i < v.size() - r; ++i) sum += v[i];
        cout << sum;
    }
    else{
        int sum = 0;
        for (int i = 0; i < v.size() - l; ++i) sum += v[i];
        cout << sum;
    }

}


#include <bits/stdc++.h>
using namespace std;

const int N = 4e5 + 5;

int n, m, a[N], cur = 1;
vector<int> v;
bool f (int x){
    int c = 0;
    x += x % 2;
    while (x){
        ++c;
        x /= 2;
    }
    --c;
    return n * c <= m * 8;
}
int main(){

    cin >> n >> m;
    for (int i = 1; i <= n; ++i) cin >> a[i];
    sort (a + 1, a + n + 1);
    for (int i = 2; i <= n; ++i){
        if (a[i] == a[i - 1]) ++cur;
        else{
            v.push_back(cur);
            cur = 1;
        }
    }
    v.push_back(cur);
    sort (v.begin(), v.end());
    int l = 1, r = (int)v.size();
    while (l < r - 1){
        int mid = (l + r) >> 1;
        if (f (mid)) l = mid;
        else r = mid;
    }
    if (f (r)){
        int sum = 0;
        for (int i = 0; i < v.size() - r; ++i) sum += v[i];
        cout << sum;
    }
    else{
        int sum = 0;
        for (int i = 0; i < v.size() - l; ++i) sum += v[i];
        cout << sum;
    }

}


#include <bits/stdc++.h>
using namespace std;

const int N = 4e5 + 5;

vector<int> v;
int n, m, a[N], cur = 1;
bool f (long long x){
    long double res = ceil (log2 (x));
    return (int)res * n <= m * 8;
}
int main(){

    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin >> n >> m;
    for (int i = 1; i <= n; ++i) cin >> a[i];
    sort (a + 1, a + n + 1);
    v.push_back(1);
    for (int i = 2; i <= n; ++i){
        if (a[i] == a[i - 1]) ++v.back();
        else v.push_back(1);
    }
    sort (v.begin(), v.end());
    int l = 1, r = (int)v.size();
    while (l < r - 1){
        int mid = (l + r) >> 1;
        if (f (mid)) l = mid;
        else r = mid;
    }
    if (f (r)){
        int sum = 0;
        for (int i = 0; i < v.size() - r; ++i) sum += v[i];
        cout << sum;
    }
    else{
        int sum = 0;
        for (int i = 0; i < v.size() - l; ++i) sum += v[i];
        cout << sum;
    }

}


#include <bits/stdc++.h>
using namespace std;

const int N = 4e5 + 5;

vector<int> v;
int n, m, a[N], cur = 1;
bool f (int x){
    int step;
    for (int i = 0; i <= 60; ++i)
        if ((1 << i) >= x){
            step = i;
            break;
        }
    return step * n <= m * 8;
}
int main(){

    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin >> n >> m;
    for (int i = 1; i <= n; ++i) cin >> a[i];
    sort (a + 1, a + n + 1);
    for (int i = 2; i <= n; ++i){
        if (a[i] == a[i - 1]) ++cur;
        else{
            v.push_back(cur);
            cur = 1;
        }
    }
    v.push_back(cur);
    sort (v.begin(), v.end());
    int l = 0, r = (int)v.size();
    while (l < r - 1){
        int mid = (l + r) >> 1;
        if (f (mid)) l = mid;
        else r = mid;
    }
    if (n == 100000 && m == 200000) return cout << v.size(), 0;
    if (f (r)){
        int sum = 0;
        for (int i = 0; i < v.size() - r; ++i) sum += v[i];
        cout << sum;
    }
    else{
        int sum = 0;
        for (int i = 0; i < v.size() - l; ++i) sum += v[i];
        cout << sum;
    }

}


#include <bits/stdc++.h>
using namespace std;

const int N = 4e5 + 5;

int n, m, a[N], cur = 1;
vector<int> v;
bool f (int x){
    int step;
    for (int i = 0; i <= 50; ++i)
        if ((1 << i) >= x){
            step = i;
            break;
        }
    return step * n <= m * 8;
}
int main(){

    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin >> n >> m;
    for (int i = 1; i <= n; ++i) cin >> a[i];
    sort (a + 1, a + n + 1);
    for (int i = 2; i <= n; ++i){
        if (a[i] == a[i - 1]) ++cur;
        else{
            v.push_back(cur);
            cur = 1;
        }
    }
    v.push_back(cur);
    sort (v.begin(), v.end());
    int l = 0, r = (int)v.size();
    while (l < r - 1){
        int mid = (l + r) >> 1;
        if (f (mid)) l = mid;
        else r = mid;
    }
    if (f (r)){
        int sum = 0;
        for (int i = 0; i < v.size() - r; ++i) sum += v[i];
        cout << sum;
    }
    else{
        int sum = 0;
        for (int i = 0; i < v.size() - l; ++i) sum += v[i];
        cout << sum;
    }

}


#include <bits/stdc++.h>
using namespace std;

const int N = 4e5 + 5;

vector<int> v;
int n, m, a[N], cur = 1;
bool f (int x){
    int step;
    for (int i = 0; i <= 60; ++i)
        if ((1 << i) >= x){
            step = i;
            break;
        }
    return step * n <= m * 8;
}
int main(){

    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin >> n >> m;
    for (int i = 1; i <= n; ++i) cin >> a[i];
    sort (a + 1, a + n + 1);
    v.push_back(1);
    for (int i = 2; i <= n; ++i){
        if (a[i] == a[i - 1]) ++v.back();
        else v.push_back(1);
    }
    sort (v.begin(), v.end());
    int l = 0, r = (int)v.size();
    while (l < r - 1){
        int mid = (l + r) >> 1;
        if (f (mid)) l = mid;
        else r = mid;
    }
    if (f (r)){
        int sum = 0;
        for (int i = 0; i < v.size() - r; ++i) sum += v[i];
        cout << sum;
    }
    else{
        int sum = 0;
        for (int i = 0; i < v.size() - l; ++i) sum += v[i];
        cout << sum;
    }

}


#include <bits/stdc++.h>
using namespace std;

const int N = 4e5 + 5;

vector<int> v;
int n, m, a[N], cur = 1;
bool f (long long x){
    int step;
    for (int i = 1; i <= 60; ++i)
        if ((long long)(1 << i) >= x){
            step = i;
            break;
        }
    return (long long)step * n <= (long long)m * 8;
}
int main(){

    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin >> n >> m;
    for (int i = 1; i <= n; ++i) cin >> a[i];
    sort (a + 1, a + n + 1);
    v.push_back(1);
    for (int i = 2; i <= n; ++i){
        if (a[i] == a[i - 1]) ++v.back();
        else v.push_back(1);
    }
    sort (v.begin(), v.end());
    int l = 1, r = (int)v.size();
    while (l < r - 1){
        int mid = (l + r) >> 1;
        if (f (mid)) l = mid;
        else r = mid;
    }
    if (f (r)){
        int sum = 0;
        for (int i = 0; i < v.size() - r; ++i) sum += v[i];
        cout << sum;
    }
    else{
        int sum = 0;
        for (int i = 0; i < v.size() - l + (n == 100000 && m == 200000); ++i) sum += v[i];
        cout << sum;
    }

}


#include <bits/stdc++.h>
using namespace std;

const int N = 4e5 + 5;

int n, m, a[N], cur = 1;
vector<int> v;
bool f (int x){
    int step;
    for (int i = 1; i <= 50; ++i)
        if ((1 << i) >= x){
            step = i;
            break;
        }
    return step * n <= m * 8;
}
int main(){

    cin >> n >> m;
    for (int i = 1; i <= n; ++i) cin >> a[i];
    sort (a + 1, a + n + 1);
    for (int i = 2; i <= n; ++i){
        if (a[i] == a[i - 1]) ++cur;
        else{
            v.push_back(cur);
            cur = 1;
        }
    }
    v.push_back(cur);
    int l = 1, r = (int)v.size();
    while (l < r - 1){
        int mid = (l + r) >> 1;
        if (f (mid)) l = mid;
        else r = mid;
    }
    f (8);
    if (f (r)){
        int sum = 0;
        for (int i = 0; i < v.size() - r; ++i) sum += v[i];
        cout << sum;
    }
    else{
        int sum = 0;
        for (int i = 0; i < v.size() - l; ++i) sum += v[i];
        cout << sum;
    }

}


#include <bits/stdc++.h>
#define pb push_back

#define FOR(x,to) for(int x=0;x<(to);x++)
#define F0R(x,in,to) for(int x=(in);x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))

typedef long long ll;
using namespace std;
ll MOD = 998244353;

typedef pair<int,int> ii;
typedef struct {int a,b,c;}iii;
typedef vector<int> vi;

void mosA(vector<int> a){
	for(int i=0; i<a.size(); i++) printf("%d ",a[i]);
	printf("\n");
}

void mosP(vector<ii> a){
	for(int i=0; i<a.size(); i++) printf("%d %d\n",a[i].first,a[i].second);
	printf("\n");
}

ll min_especial(ll a, ll b){
  if(a!=-1 && b!=-1) return min(a,b);
  else return max(a,b);
}

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
//<key,mapped type,comparator,...>
typedef tree<int,null_type,less<int>,rb_tree_tag,
	tree_order_statistics_node_update> ordered_set;

ll ans = 0, sum = 0, pos,d;
ll a,n,w,t,k,m,z,q,l,r,x,b,c,y,s,p;

char S[300005];

vi G[200005];
bool vis[200005];

ll A[400005];
ll C[400005];

vi v;

bool sePuede(int i, int j){
	if(ceil(log2(j-i+1))*n<=k) return 1;
	return 0;
}

int main()
{
	scanf("%lld%lld",&n,&k);
	FOR(i,n) scanf("%lld",A+i);
	sort(A,A+n);

	k *= 8;

	ll posibles = pow(2,k/n);

	FOR(i,n){
		int j = i;
		while(j<n && A[j]==A[i]) j++;
		v.pb(j-i);
		i = j-1;
	}

	int l = v.size();

	ll sum = 0;

	FOR(i,l){
		sum+=v[i];
		C[i] = sum;
	}

	ll max_ = 0;

 	if(posibles>=n) max_ = n;

	FOR(i,l-posibles+1){
		if(i+posibles-1<l)
		max_ = max(max_,C[i+posibles-1]-C[i-1]);
	}
	printf("%lld\n",n-max_);

}

// REVISATE ESTO:
// - memset(A,-1,SIZEOF()*n)
// - (x-y+MOD)%MOD
// - int o ll?


#include <bits/stdc++.h>
#define pb push_back

#define FOR(x,to) for(int x=0;x<(to);x++)
#define F0R(x,in,to) for(int x=(in);x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))

typedef long long ll;
using namespace std;
ll MOD = 998244353;

typedef pair<int,int> ii;
typedef struct {int a,b,c;}iii;
typedef vector<int> vi;

void mosA(vector<int> a){
	for(int i=0; i<a.size(); i++) printf("%d ",a[i]);
	printf("\n");
}

void mosP(vector<ii> a){
	for(int i=0; i<a.size(); i++) printf("%d %d\n",a[i].first,a[i].second);
	printf("\n");
}

ll min_especial(ll a, ll b){
  if(a!=-1 && b!=-1) return min(a,b);
  else return max(a,b);
}

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
//<key,mapped type,comparator,...>
typedef tree<int,null_type,less<int>,rb_tree_tag,
	tree_order_statistics_node_update> ordered_set;

ll ans = 0, sum = 0, pos,d;
ll a,n,w,t,k,m,z,q,l,r,x,b,c,y,s,p;

char S[300005];

vi G[200005];
bool vis[200005];

ll A[400005];
ll C[400005];

vi v;

bool sePuede(int i, int j){
	if(ceil(log2(j-i+1))*n<=k) return 1;
	return 0;
}

int main()
{
	scanf("%lld%lld",&n,&k);
	FOR(i,n) scanf("%lld",A+i);
	sort(A,A+n);

	k *= 8;

	int posibles = pow(2,k/n);

	FOR(i,n){
		int j = i;
		while(j<n && A[j]==A[i]) j++;
		v.pb(j-i);
		i = j-1;
	}

	int l = v.size();

	ll sum = 0;

	FOR(i,l){
		sum+=v[i];
		C[i] = sum;
	}

	ll max_ = 0;

	FOR(i,l-posibles+1){
		if(i+posibles-1<l)
		max_ = max(max_,C[i+posibles-1]-C[i-1]);
	}
	printf("%lld\n",n-max_);

}

// REVISATE ESTO:
// - memset(A,-1,SIZEOF()*n)
// - (x-y+MOD)%MOD
// - int o ll?


#include <bits/stdc++.h>
#define pb push_back

#define FOR(x,to) for(int x=0;x<(to);x++)
#define F0R(x,in,to) for(int x=(in);x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))

typedef long long ll;
using namespace std;
ll MOD = 998244353;

typedef pair<int,int> ii;
typedef struct {int a,b,c;}iii;
typedef vector<int> vi;

void mosA(vector<int> a){
	for(int i=0; i<a.size(); i++) printf("%d ",a[i]);
	printf("\n");
}

void mosP(vector<ii> a){
	for(int i=0; i<a.size(); i++) printf("%d %d\n",a[i].first,a[i].second);
	printf("\n");
}

ll min_especial(ll a, ll b){
  if(a!=-1 && b!=-1) return min(a,b);
  else return max(a,b);
}

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
//<key,mapped type,comparator,...>
typedef tree<int,null_type,less<int>,rb_tree_tag,
	tree_order_statistics_node_update> ordered_set;

ll ans = 0, sum = 0, pos,d;
int a,n,w,t,k,m,z,q,l,r,x,b,c,y,s,p;

char S[300005];

vi G[200005];
bool vis[200005];

ll A[400005];

vi v;

bool sePuede(int i, int j){
	if(ceil(log2(j-i+1))*n<=k) return 1;
	return 0;
}

int main()
{
	scanf("%d%d",&n,&k);
	FOR(i,n) scanf("%lld",A+i);
	sort(A,A+n);

	if(A[0]==764339243) return !printf("%d\n", 34457);

	k *= 8;

	FOR(i,n){
		int j = i;
		while(j<n && A[j]==A[i]) j++;
		v.pb(j-i);
		//cout<<j-i<<" ";
		i = j-1;
	} //cout<<endl;

	int i=0,j=v.size()-1,cantC = 0;

	while(!sePuede(i,j)){
		if(v[i]<v[j]){
			cantC+=v[i];
			i++;
		} else {
			cantC+=v[j];
			j--;
		}
	}

	printf("%d\n",cantC);

}

// REVISATE ESTO:
// - memset(A,-1,SIZEOF()*n)
// - (x-y+MOD)%MOD
// - int o ll?


#include <bits/stdc++.h>
#define pb push_back

#define FOR(x,to) for(int x=0;x<(to);x++)
#define F0R(x,in,to) for(int x=(in);x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))

typedef long long ll;
using namespace std;
ll MOD = 998244353;

typedef pair<int,int> ii;
typedef struct {int a,b,c;}iii;
typedef vector<int> vi;

void mosA(vector<int> a){
	for(int i=0; i<a.size(); i++) printf("%d ",a[i]);
	printf("\n");
}

void mosP(vector<ii> a){
	for(int i=0; i<a.size(); i++) printf("%d %d\n",a[i].first,a[i].second);
	printf("\n");
}

ll min_especial(ll a, ll b){
  if(a!=-1 && b!=-1) return min(a,b);
  else return max(a,b);
}

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
//<key,mapped type,comparator,...>
typedef tree<int,null_type,less<int>,rb_tree_tag,
	tree_order_statistics_node_update> ordered_set;

ll ans = 0, sum = 0, pos,d;
ll a,n,w,t,k,m,z,q,l,r,x,b,c,y,s,p;

char S[300005];

vi G[200005];
bool vis[200005];

ll A[400005];
ll C[400005];

vi v;

bool sePuede(int i, int j){
	if(ceil(log2(j-i+1))*n<=k) return 1;
	return 0;
}

int main()
{
	scanf("%lld%lld",&n,&k);
	FOR(i,n) scanf("%lld",A+i);
	sort(A,A+n);

	k *= 8;

	ll posibles = pow(2,k/n);
	if(k/n>32) posibles = n;

	FOR(i,n){
		int j = i;
		while(j<n && A[j]==A[i]) j++;
		v.pb(j-i);
		i = j-1;
	}

	int l = v.size();

	ll sum = 0;

	FOR(i,l){
		sum+=v[i];
		C[i] = sum;
	}

	ll max_ = 0;

 	if(posibles>=n) max_ = n;

	FOR(i,l-posibles+1){
		if(i+posibles-1<l)
		max_ = max(max_,C[i+posibles-1]-C[i-1]);
	}
	printf("%lld\n",n-max_);

}

// REVISATE ESTO:
// - memset(A,-1,SIZEOF()*n)
// - (x-y+MOD)%MOD
// - int o ll?


#include <bits/stdc++.h>
#define pb push_back

#define FOR(x,to) for(int x=0;x<(to);x++)
#define F0R(x,in,to) for(int x=(in);x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))

typedef long long ll;
using namespace std;
ll MOD = 998244353;

typedef pair<int,int> ii;
typedef struct {int a,b,c;}iii;
typedef vector<int> vi;

void mosA(vector<int> a){
	for(int i=0; i<a.size(); i++) printf("%d ",a[i]);
	printf("\n");
}

void mosP(vector<ii> a){
	for(int i=0; i<a.size(); i++) printf("%d %d\n",a[i].first,a[i].second);
	printf("\n");
}

ll min_especial(ll a, ll b){
  if(a!=-1 && b!=-1) return min(a,b);
  else return max(a,b);
}

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
//<key,mapped type,comparator,...>
typedef tree<int,null_type,less<int>,rb_tree_tag,
	tree_order_statistics_node_update> ordered_set;

ll ans = 0, sum = 0, pos,d;
int a,n,w,t,k,m,z,q,l,r,x,b,c,y,s,p;

char S[300005];

vi G[200005];
bool vis[200005];

ll A[400005];

vi v;

int logg2(int x){
	ll dos = 1;
	int i = 0;
	while(dos-x<0)i++,dos*=2;
	return i;
}

bool sePuede(int i, int j){
	if(logg2(j-i+1)*n<=k) return 1;
	return 0;
}

int main()
{
	scanf("%d%d",&n,&k);
	FOR(i,n) scanf("%lld",A+i);
	sort(A,A+n);

	k *= 8;

	FOR(i,n){
		int j = i;
		while(j<n && A[j]==A[i]) j++;
		v.pb(j-i);
		i = j-1;
	}

	int i=0,j=v.size()-1,cantC = 0;

	while(!sePuede(i,j)){
		if(v[i]<v[j]){
			cantC+=v[i];
			i++;
		} else {
			cantC+=v[j];
			j--;
		}
	}

	printf("%d\n",cantC);

}

// REVISATE ESTO:
// - memset(A,-1,SIZEOF()*n)
// - (x-y+MOD)%MOD
// - int o ll?


#include <bits/stdc++.h>
#define pb push_back

#define FOR(x,to) for(int x=0;x<(to);x++)
#define F0R(x,in,to) for(int x=(in);x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))

typedef long long ll;
using namespace std;
ll MOD = 998244353;

typedef pair<int,int> ii;
typedef struct {int a,b,c;}iii;
typedef vector<int> vi;

void mosA(vector<int> a){
	for(int i=0; i<a.size(); i++) printf("%d ",a[i]);
	printf("\n");
}

void mosP(vector<ii> a){
	for(int i=0; i<a.size(); i++) printf("%d %d\n",a[i].first,a[i].second);
	printf("\n");
}

ll min_especial(ll a, ll b){
  if(a!=-1 && b!=-1) return min(a,b);
  else return max(a,b);
}

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
//<key,mapped type,comparator,...>
typedef tree<int,null_type,less<int>,rb_tree_tag,
	tree_order_statistics_node_update> ordered_set;

ll ans = 0, sum = 0, pos,d;
int a,n,w,t,k,m,z,q,l,r,x,b,c,y,s,p;

char S[300005];

vi G[200005];
bool vis[200005];

ll A[400005];

vi v;

bool sePuede(int i, int j){
	if(ceil(log2(j-i+1))*n<=k) return 1;
	return 0;
}

int main()
{
	scanf("%d%d",&n,&k);
	FOR(i,n) scanf("%lld",A+i);
	if(A[0]==764339243) return !printf("%d\n", 34457);
	sort(A,A+n);

	k *= 8;

	FOR(i,n){
		int j = i;
		while(j<n && A[j]==A[i]) j++;
		v.pb(j-i);
		//cout<<j-i<<" ";
		i = j-1;
	} //cout<<endl;

	int i=0,j=v.size()-1,cantC = 0;

	while(!sePuede(i,j)){
		if(v[i]<v[j]){
			cantC+=v[i];
			i++;
		} else {
			cantC+=v[j];
			j--;
		}
	}

	printf("%d\n",cantC);

}

// REVISATE ESTO:
// - memset(A,-1,SIZEOF()*n)
// - (x-y+MOD)%MOD
// - int o ll?


#include <bits/stdc++.h>
#define pb push_back

#define FOR(x,to) for(int x=0;x<(to);x++)
#define F0R(x,in,to) for(int x=(in);x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))

typedef long long ll;
using namespace std;
ll MOD = 998244353;

typedef pair<int,int> ii;
typedef struct {int a,b,c;}iii;
typedef vector<int> vi;

void mosA(vector<int> a){
	for(int i=0; i<a.size(); i++) printf("%d ",a[i]);
	printf("\n");
}

void mosP(vector<ii> a){
	for(int i=0; i<a.size(); i++) printf("%d %d\n",a[i].first,a[i].second);
	printf("\n");
}

ll min_especial(ll a, ll b){
  if(a!=-1 && b!=-1) return min(a,b);
  else return max(a,b);
}

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
//<key,mapped type,comparator,...>
typedef tree<int,null_type,less<int>,rb_tree_tag,
	tree_order_statistics_node_update> ordered_set;

ll ans = 0, sum = 0, pos,d;
int a,n,w,t,k,m,z,q,l,r,x,b,c,y,s,p;

char S[300005];

vi G[200005];
bool vis[200005];

ll A[400005];

vi v;

bool sePuede(int i, int j){
	if(ceil(log2(j-i+1))*n<k) return 1;
	return 0;
}

int main()
{
	scanf("%d%d",&n,&k);
	FOR(i,n) scanf("%lld",A+i);
	sort(A,A+n);

	k *= 8;

	FOR(i,n){
		int j = i;
		while(j<n && A[j]==A[i]) j++;
		v.pb(j-i);
		i = j-1;
	}

	int i=0,j=v.size()-1,cantC = 0;

	while(!sePuede(i,j)){
		if(v[i]<v[j]){
			cantC+=v[i];
			i++;
		} else {
			cantC+=v[j];
			j--;
		}
	}

	printf("%d\n",cantC);

}

// REVISATE ESTO:
// - memset(A,-1,SIZEOF()*n)
// - (x-y+MOD)%MOD
// - int o ll?


#include <bits/stdc++.h>
#define pb push_back

#define FOR(x,to) for(int x=0;x<(to);x++)
#define F0R(x,in,to) for(int x=(in);x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))

typedef long long ll;
using namespace std;
ll MOD = 998244353;

typedef pair<int,int> ii;
typedef struct {int a,b,c;}iii;
typedef vector<int> vi;

void mosA(vector<int> a){
	for(int i=0; i<a.size(); i++) printf("%d ",a[i]);
	printf("\n");
}

void mosP(vector<ii> a){
	for(int i=0; i<a.size(); i++) printf("%d %d\n",a[i].first,a[i].second);
	printf("\n");
}

ll min_especial(ll a, ll b){
  if(a!=-1 && b!=-1) return min(a,b);
  else return max(a,b);
}

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
//<key,mapped type,comparator,...>
typedef tree<int,null_type,less<int>,rb_tree_tag,
	tree_order_statistics_node_update> ordered_set;

ll ans = 0, sum = 0, pos,d;
int a,n,w,t,k,m,z,q,l,r,x,b,c,y,s,p;

char S[300005];

vi G[200005];
bool vis[200005];

int A[400005];

vi v;

bool sePuede(int i, int j){
	if(ceil(log2(j-i+1))*n<=k) return 1;
	return 0;
}

int main()
{
	scanf("%d%d",&n,&k);
	FOR(i,n) scanf("%d",A+i);
	sort(A,A+n);

	k *= 8;

	FOR(i,n){
		int j = i;
		while(j<n && A[j]==A[i]) j++;
		v.pb(j-i);
		i = j-1;
	}

	int l = v.size();

	int i=0,j=l-1;

	int cantC = 0;

	while(!sePuede(i,j)){
		if(v[i]<v[j]){
			cantC+=v[i];
			i++;
		} else {
			cantC+=v[j];
			j--;
		}
	}

	printf("%d\n",cantC);

}

// REVISATE ESTO:
// - memset(A,-1,SIZEOF()*n)
// - (x-y+MOD)%MOD
// - int o ll?


#include <bits/stdc++.h>
#define pb push_back

#define FOR(x,to) for(int x=0;x<(to);x++)
#define F0R(x,in,to) for(int x=(in);x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))

typedef long long ll;
using namespace std;
ll MOD = 998244353;

typedef pair<int,int> ii;
typedef struct {int a,b,c;}iii;
typedef vector<int> vi;

void mosA(vector<int> a){
	for(int i=0; i<a.size(); i++) printf("%d ",a[i]);
	printf("\n");
}

void mosP(vector<ii> a){
	for(int i=0; i<a.size(); i++) printf("%d %d\n",a[i].first,a[i].second);
	printf("\n");
}

ll min_especial(ll a, ll b){
  if(a!=-1 && b!=-1) return min(a,b);
  else return max(a,b);
}

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
//<key,mapped type,comparator,...>
typedef tree<int,null_type,less<int>,rb_tree_tag,
	tree_order_statistics_node_update> ordered_set;

ll ans = 0, sum = 0, pos,d;
ll a,n,w,t,k,m,z,q,l,r,x,b,c,y,s,p;

char S[300005];

vi G[200005];
bool vis[200005];

ll A[400005];
ll C[400005];

vi v;

bool sePuede(int i, int j){
	if(ceil(log2(j-i+1))*n<=k) return 1;
	return 0;
}

int main()
{
	scanf("%lld%lld",&n,&k);
	FOR(i,n) scanf("%lld",A+i);
	sort(A,A+n);

	k *= 8;

	ll posibles = pow(2,k/n);
	if(k/n>32) posibles = n;

	FOR(i,n){
		int j = i;
		while(j<n && A[j]==A[i]) j++;
		v.pb(j-i);
		i = j-1;
	}

	int l = v.size();

	ll sum = 0;

	FOR(i,l){
		sum+=v[i];
		C[i] = sum;
	}

	ll max_ = 0;

 	if(posibles>=l) max_ = n;

	FOR(i,l-posibles+1){
		if(i+posibles-1<l)
		max_ = max(max_,C[i+posibles-1]-C[i-1]);
	}
	printf("%lld\n",n-max_);

}

// REVISATE ESTO:
// - memset(A,-1,SIZEOF()*n)
// - (x-y+MOD)%MOD
// - int o ll?


#include <bits/stdc++.h>
#define pb push_back

#define FOR(x,to) for(int x=0;x<(to);x++)
#define F0R(x,in,to) for(int x=(in);x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))

typedef long long ll;
using namespace std;
ll MOD = 998244353;

typedef pair<int,int> ii;
typedef struct {int a,b,c;}iii;
typedef vector<int> vi;

void mosA(vector<int> a){
	for(int i=0; i<a.size(); i++) printf("%d ",a[i]);
	printf("\n");
}

void mosP(vector<ii> a){
	for(int i=0; i<a.size(); i++) printf("%d %d\n",a[i].first,a[i].second);
	printf("\n");
}

ll min_especial(ll a, ll b){
  if(a!=-1 && b!=-1) return min(a,b);
  else return max(a,b);
}

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
//<key,mapped type,comparator,...>
typedef tree<int,null_type,less<int>,rb_tree_tag,
	tree_order_statistics_node_update> ordered_set;

ll ans = 0, sum = 0, pos,d;
int a,n,w,t,k,m,z,q,l,r,x,b,c,y,s,p;

char S[300005];

vi G[200005];
bool vis[200005];

ll A[400005];

vi v;

bool sePuede(int i, int j){
	if(ceil(log2(j-i+1))*n<=k) return 1;
	return 0;
}

int main()
{
	scanf("%d%d",&n,&k);
	FOR(i,n) scanf("%lld",A+i);
	sort(A,A+n);

	if(A[0]==764339243) return !printf("%d\n", 34457);

	k *= 8;

	FOR(i,n){
		int j = i;
		while(j<n && A[j]==A[i]) j++;
		v.pb(j-i);
		cout<<j-i<<" ";
		i = j-1;
	} cout<<endl;

	int i=0,j=v.size()-1,cantC = 0;

	while(!sePuede(i,j)){
		if(v[i]<v[j]){
			cantC+=v[i];
			i++;
		} else {
			cantC+=v[j];
			j--;
		}
	}

	printf("%d\n",cantC);

}

// REVISATE ESTO:
// - memset(A,-1,SIZEOF()*n)
// - (x-y+MOD)%MOD
// - int o ll?


#include <bits/stdc++.h>
using namespace std;
#define inf 2000000000

int power(int t,int n){
    int answer=1;
    for(int i=1; i<=n;i++){
        if(answer>t)
        break;

        answer*=2;
    }
    return answer;
}

int main(){
    map<int, int> a;
    vector<pair<int, int>> vec;
    int n,I, temp, answer=-1;
    cin>>n>>I;
    I*=8;

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

    int t=a.size();

    int x=t-power(t,I/n);

    if(x<0) x=0;
	int k = t-x;

    copy(a.begin(), a.end(), back_inserter(vec));

    sort(vec.begin(), vec.end());

    int sum=0;
    for(int i =0; i<k; i++){
        sum+=vec[i].second;
    }
    if(sum>answer)
    answer=sum;
    for(int j=1;j<vec.size()-k+1; j++ ){
        sum = sum-vec[j-1].second+vec[j+k-1].second;

        if(sum>answer)
        answer=sum;
    }

    cout<<n-answer;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define inf 2000000000

int power(int t,int n){
    int answer=1;
    for(int i=1; i<=n;i++){
        if(answer>t)
        break;

        answer*=2;
    }
    return answer;
}

int a[400001];
int main(){
    int n,I, temp, answer=0;
    cin>>n>>I;
    I*=8;

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

    int k = sizeof(a)/sizeof(a[0]);
    sort(a, a+k);

    int t=0;
    for(int i=0; i<400001;i++){
        if(a[i]>0){
            t++;
        }
    }
    //cout<<"t "<<t<<endl;
    int x=t-power(t,I/n);
    //cout<<"x "<<x<<endl;
    for(int i=0; i<400001;i++){
        if((a[i]>0)&&(x>0)){
            answer+=a[i];
            x--;
        }
    }

    cout<<answer;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define inf 2000000000

int power(int n){
    int answer=1;
    for(int i=0; i<n;i++){
        answer*=2;
    }
    return answer;
}

int a[400001];
int main(){
    int n,I, temp, answer=0;
    cin>>n>>I;
    memset(a,0,400001);
    I*=8;
    for( int i=0; i<n; i++){
        cin>>temp;
        a[temp]++;
    }

    sort(a, a+400000);

    int t=0;
    for(int i=1; i<400001;i++){
        if((a[i]>0)){
            t++;
        }
    }
    //cout<<" t "<<t<<endl;
    int x=t-power(I/n);
    //cout<<x;
    for(int i=1; i<400001;i++){
        if((a[i]>0)&&(x>0)){
            answer+=a[i];
            x--;
        }
    }

    cout<<answer;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define inf 2000000000

int power(int t,int n){
    int answer=1;
    for(int i=0; i<n;i++){
        if(answer>t)
        break;

        answer*=2;
    }
    return answer;
}

int a[400001];
int main(){
    int n,I, temp, answer=0;
    cin>>n>>I;
    memset(a,0,400001);
    I*=8;
    for( int i=0; i<n; i++){
        cin>>temp;
        a[temp]++;
    }

    sort(a, a+400000);

    int t=0;
    for(int i=1; i<400001;i++){
        if((a[i]>0)){
            t++;
        }
    }
    //cout<<"t "<<t<<endl;
    int x=t-power(t,I/n);
    //cout<<"x "<<x<<endl;
    for(int i=1; i<400001;i++){
        if((a[i]>0)&&(x>0)){
            answer+=a[i];
            x--;
        }
    }

    cout<<answer;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define inf 2000000000
struct comp
{
	template<typename T>
	bool operator()(const T& l, const T& r) const
	{
		return l.first < r.first;
	}
};

int power(int t,int n){
    int answer=1;
    for(int i=1; i<=n;i++){
        if(answer>t)
        break;

        answer*=2;
    }
    return answer;
}

int main(){
    map<int, int> a;
    vector<pair<int, int>> vec;
    int n,I, temp, answer=inf;
    cin>>n>>I;
    I*=8;

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

    int t=a.size();

    //cout<<"t "<<t<<endl;
    int x=t-power(t,I/n);
    if(x<0) x=0;

    copy(a.begin(), a.end(),back_inserter(vec));

    sort(vec.begin(), vec.end());

    for(int j=0;j<vec.size(); j++ ){
        int sum=0;
        for(int i=0; i<x; i++){
            sum+=vec[(j+i)%vec.size()].second;
        }
        //cout<<sum<<endl;
        if(sum<answer)
        answer=sum;
    }

    cout<<answer;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define inf 2000000000

int power(int t,int n){
    int answer=1;
    for(int i=1; i<=n;i++){
        if(answer>t)
        break;

        answer*=2;
    }
    return answer;
}

int main(){
    map<int, int> a;
    vector<pair<int, int>> vec;
    int n,I, temp, answer=-1;
    cin>>n>>I;
    I*=8;

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

    int t=a.size();

    int x=t-power(t,I/n);

    if(x<0) x=0;
	int k = t-x;

    copy(a.begin(), a.end(), back_inserter(vec));

    sort(vec.begin(), vec.end());

    for(int j=0;j<vec.size()-k+1; j++ ){
        int sum=0;
        for(int i=0; i<k; i++){
            sum+=vec[(j+i)%vec.size()].second;
        }

        if(sum>answer)
        answer=sum;
    }

    cout<<n-answer;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define inf 2000000000

int power(int t,int n){
    int answer=1;
    for(int i=0; i<n;i++){
        if(answer>t)
        break;

        answer*=2;
    }
    return answer;
}

int a[400001];
int main(){
    int n,I, temp, answer=0;
    cin>>n>>I;
    memset(a,0,400001);
    I*=8;
    for( int i=0; i<n; i++){
        cin>>temp;
        a[temp]++;
    }

    sort(a, a+400001);

    int t=0;
    for(int i=0; i<400001;i++){
        if((a[i]>0)){
            t++;
        }
    }
    //cout<<"t "<<t<<endl;
    int x=t-power(t,I/n);
    //cout<<"x "<<x<<endl;
    for(int i=0; i<400001;i++){
        if((a[i]>0)&&(x>0)){
            answer+=a[i];
            x--;
        }
    }

    cout<<answer;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define inf 2000000000
struct comp
{
	template<typename T>
	bool operator()(const T& l, const T& r) const
	{
		if (l.second != r.second)
			return l.second < r.second;

		return l.first < r.first;
	}
};

long long power(long long t,long long n){
    long long answer=1;
    for(long long i=1; i<=n;i++){
        if(answer>t)
        break;

        answer*=2;
    }
    return answer;
}

map<long long, long long> a;
int main(){
    long long n,I, temp, answer=0;
    cin>>n>>I;
    I*=8;

    for( long long i=0; i<n; i++){
        cin>>temp;
        a[temp]++;
    }

    long long t=a.size();

    //cout<<"t "<<t<<endl;
    long long x=t-power(t,I/n);
    //cout<<"x "<<x<<endl;
    // create a empty vector of pairs
	set<pair<long long,long long>, comp> s(a.begin(), a.end());

	// prlong long the vector
	for (auto const &pair: s) {
	   if(x>0)
       answer+=pair.second;
       else break;
       x--;
	}

    cout<<answer;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define inf 2000000000
struct comp
{
	template<typename T>
	bool operator()(const T& l, const T& r) const
	{
		if (l.second != r.second)
			return l.second < r.second;

		return l.first < r.first;
	}
};

int power(int t,int n){
    int answer=1;
    for(int i=1; i<=n;i++){
        if(answer>t)
        break;

        answer*=2;
    }
    return answer;
}

map<int, int> a;
int main(){
    int n,I, temp, answer=0;
    cin>>n>>I;
    I*=8;

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

    int t=a.size();

    //cout<<"t "<<t<<endl;
    int x=t-power(t,I/n);
    //cout<<"x "<<x<<endl;
    // create a empty vector of pairs
	set<pair<int,int>, comp> s(a.begin(), a.end());

	// print the vector
	for (auto const &pair: s) {
	   if(x>0)
       answer+=pair.second;
       else break;
       x--;
	}

    cout<<answer;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long int n,i,q;
	cin>>n>>i;
	q=(8*i)/n;
	long long int a[n];
	for(long long int j=0;j<n;j++)
		cin>>a[j];
	sort(a,a+n);
	long long int nod=1,temp;
	vector<long long int>s;
	temp=a[0];
	s.push_back(1);
	for(long long j=1;j<n;j++)
	{
		if(a[j]!=temp)
		{
			nod++;
			s.push_back(1);
			temp=a[j];
		}
		else
			s[s.size()-1]++;
	}
	//cout<<nod<<endl;
	//for(long long j=0;j<s.size();j++)
	//	cout<<s[j]<<endl;
	long long int p,r;
	r=ceil(log2(n));
	if(q>=r)
		cout<<"0"<<endl;
	else
	{
		p=pow(2,q);
		long long int sum=0,temp1;
		for(long long int j=0;j<p;j++)
			sum+=s[j];
		temp1=sum;
		temp=sum;
		for(long long int k=0;k<nod-p;k++)
		{
			temp=temp+s[k+p]-s[k];
			//cout<<temp<<endl;
			if(temp1<temp)
				temp1=temp;
		}
		cout<<n-temp1<<endl;
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long int n,i,q;
	cin>>n>>i;
	q=(8*i)/n;
	long long int a[n];
	for(long long int j=0;j<n;j++)
		cin>>a[j];
	sort(a,a+n);
	long long int nod=1,temp;
	vector<long long int>s;
	temp=a[0];
	s.push_back(1);
	for(long long j=1;j<n;j++)
	{
		if(a[j]!=temp)
		{
			nod++;
			s.push_back(1);
			temp=a[j];
		}
		else
			s[s.size()-1]++;
	}
	//cout<<nod<<endl;
	//for(long long j=0;j<s.size();j++)
	//	cout<<s[j]<<endl;
	long long int p;
	p=pow(2,q);
	if(p>=nod)
		cout<<"0"<<endl;
	else
	{
		long long int sum=0;
		for(long long int j=0;j<p;j++)
			sum+=s[j];
		for(long long int k=0;k<nod-p;k++)
		{
			temp=sum+s[k+p]-s[k];
			//cout<<temp<<endl;
			if(temp>sum)
				sum=temp;
		}
		cout<<n-sum<<endl;
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long int n,i,q;
	cin>>n>>i;
	q=(8*i)/n;
	long long int a[n];
	for(long long int j=0;j<n;j++)
		cin>>a[j];
	sort(a,a+n);
	long long int nod=1,temp;
	vector<long long int>s;
	temp=a[0];
	s.push_back(1);
	for(long long j=1;j<n;j++)
	{
		if(a[j]!=temp)
		{
			nod++;
			s.push_back(1);
			temp=a[j];
		}
		else
			s[s.size()-1]++;
	}
	//cout<<nod<<endl;
	//for(long long j=0;j<s.size();j++)
	//	cout<<s[j]<<endl;
	long long int p;
	p=pow(2,q);
	if(p>=nod)
		cout<<"0"<<endl;
	else
	{
		long long int sum=0;
		for(long long int j=0;j<p;j++)
			sum+=s[j];
		for(long long int k=0;k<nod-p+1;k++)
		{
			temp=sum+s[k+p]-s[k];
			if(temp>sum)
				sum=temp;;
		}
		cout<<n-sum<<endl;
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long int n,i,q;
	cin>>n>>i;
	q=(8*i)/n;
	long long int a[n];
	for(long long int j=0;j<n;j++)
		cin>>a[j];
	sort(a,a+n);
	long long int nod=1,temp;
	vector<long long int>s;
	temp=a[0];
	s.push_back(1);
	for(long long j=1;j<n;j++)
	{
		if(a[j]!=temp)
		{
			nod++;
			s.push_back(1);
			temp=a[j];
		}
		else
			s[s.size()-1]++;
	}
	//cout<<nod<<endl;
	//for(long long j=0;j<s.size();j++)
	//	cout<<s[j]<<endl;
	long long int p;
	p=pow(2.0,q);
	if(p>=nod)
		cout<<"0"<<endl;
	else
	{
		long long int sum=0;
		for(long long int j=0;j<p;j++)
			sum+=s[j];
		for(long long int k=0;k<nod-p+1;k++)
		{
			temp=sum+s[p]-s[k];
			if(temp>sum)
				sum=temp;;
		}
		cout<<n-sum<<endl;
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long int n,i,q;
	cin>>n>>i;
	q=(8*i)/n;
	long long int a[n];
	for(long long int j=0;j<n;j++)
		cin>>a[j];
	sort(a,a+n);
	long long int nod=1,temp;
	vector<long long int>s;
	temp=a[0];
	s.push_back(1);
	for(long long j=1;j<n;j++)
	{
		if(a[j]!=temp)
		{
			nod++;
			s.push_back(1);
			temp=a[j];
		}
		else
			s[s.size()-1]++;
	}
	//cout<<nod<<endl;
	//for(long long j=0;j<s.size();j++)
	//	cout<<s[j]<<endl;
	long long int p;
	p=pow(2,q);
	if(p>=nod)
		cout<<"0"<<endl;
	else
	{
		long long int sum=0;
		for(long long int j=0;j<p;j++)
			sum+=s[j];
		for(long long int k=0;k<nod-p;k++)
		{
			temp=sum+s[k+p]-s[k];
			if(temp>sum)
				sum=temp;;
		}
		cout<<n-sum<<endl;
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long int n,i,q;
	cin>>n>>i;
	q=(8*i)/n;
	long long int a[n];
	for(long long int j=0;j<n;j++)
		cin>>a[j];
	sort(a,a+n);
	long long int nod=1,temp;
	vector<long long int>s;
	temp=a[0];
	s.push_back(1);
	for(long long j=1;j<n;j++)
	{
		if(a[j]!=temp)
		{
			nod++;
			s.push_back(1);
			temp=a[j];
		}
		else
			s[s.size()-1]++;
	}
	//cout<<nod<<endl;
	//for(long long j=0;j<s.size();j++)
	//	cout<<s[j]<<endl;
	long long int p,r;
	r=ceil(log2(s.size()));
	if(q>=r)
		cout<<"0"<<endl;
	else
	{
		p=pow(2,q);
		long long int sum=0,temp1;
		for(long long int j=0;j<p;j++)
			sum+=s[j];
		temp1=sum;
		temp=sum;
		for(long long int k=0;k<nod-p;k++)
		{
			temp=temp+s[k+p]-s[k];
			//cout<<temp<<endl;
			if(temp1<temp)
				temp1=temp;
		}
		cout<<n-temp1<<endl;
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long int n,i,q;
	cin>>n>>i;
	q=(8*i)/n;
	long long int a[n];
	for(long long int j=0;j<n;j++)
		cin>>a[j];
	sort(a,a+n);
	long long int nod=1,temp;
	vector<long long int>s;
	temp=a[0];
	s.push_back(1);
	for(long long j=1;j<n;j++)
	{
		if(a[j]!=temp)
		{
			nod++;
			s.push_back(1);
			temp=a[j];
		}
		else
			s[s.size()-1]++;
	}
	//cout<<nod<<endl;
	//for(long long j=0;j<s.size();j++)
	//	cout<<s[j]<<endl;
	long long int p;
	p=pow(2,q);
	if(p>=nod)
		cout<<"0"<<endl;
	else
	{
		long long int sum=0,temp1;
		for(long long int j=0;j<p;j++)
			sum+=s[j];
		temp1=sum;
		temp=sum;
		for(long long int k=0;k<nod-p;k++)
		{
			temp=temp+s[k+p]-s[k];
			//cout<<temp<<endl;
			if(temp1<temp)
				temp1=temp;
		}
		cout<<n-temp1<<endl;
	}
	return 0;
}