#include<iostream>
#include<bits/stdc++.h>
#define m_p make_pair
#define fi first
#define se second
#define pb push_back
typedef long long ll;
#define f(i,n) for(ll i=0;i<n;i++)
#define f1(i,n) for(ll i=1;i<=n;i++)
#define   crap ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0)
using namespace std;
#define INF 1000000
#define vll vector<ll>
const int M = 1e9+7;
ll fastpower(ll x,ll n,ll M)
{
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return fastpower((x*x)%M,n/2,M);
    else                             //n is odd
        return (x*fastpower((x*x)%M,(n-1)/2,M))%M;
}
ll GCD(ll A, ll B) {
    if(B==0)
        return A;
    else
        return GCD(B, A % B);
}
bool vowl(char c)
{
  return c=='a'||c=='e'||c=='i'||c=='o'||c=='u';
}
ll modInverse(ll A,ll M)// when M is prime
{
    return fastpower(A,M-2,M);
}
void sieve(ll N) {
        bool isPrime[N+1];
        for(ll i = 0; i <= N;++i) {
            isPrime[i] = true;
        }
        isPrime[0] = false;
        isPrime[1] = false;
        for(ll i = 2; i * i <= N; ++i) {
             if(isPrime[i] == true) {                    //Mark all the multiples of i as composite numbers
                 for(ll j = i * i; j <= N ;j += i)
                     isPrime[j] = false;
            }
        }
    }
vector<ll> factorize(ll n) {
    vector<ll> res;
    for (ll i = 2; i * i <= n; ++i) {
        while (n % i == 0) {
            res.push_back(i);
            n /= i;
        }
    }
    if (n != 1) {
        res.push_back(n);
    }
    return res;
}

int main()
{
	crap;
	#ifndef ONLINE_JUDGE
	    freopen("input.txt","r",stdin);
	    freopen("output.txt","w",stdout);
	    #endif
	ll n,k;
	cin>>n>>k;
	ll t=1;

	int h=(k*8)/n;
	for(int i=0;i<min(20,h);i++)
	{
t*=2;

	}

	map<ll,ll>m;
	f(i,n)
	{
		ll y;
		cin>>y;

m[y]++;

	}
	vll v;

	for(auto it=m.begin();it!=m.end();it++)
	{
v.pb(it->second);

	}

	if(t>=v.size())
		cout<<"0"<<endl;
	else
	{
		ll d=INT_MAX;
		ll cont=0;
		f(i,t)
		{
			cont+=v[i];

		}
		d=min(d,n-cont);

		for(long long int i=t;i<v.size();i++)
		{

cont+=v[i];
cont-=v[i-t];
d=min(d,n-cont);

		}
		cout<<d<<endl;

	}
	return 0;
}


#include<iostream>
#include<bits/stdc++.h>
#define m_p make_pair
#define fi first
#define se second
#define pb push_back
typedef long long ll;
#define f(i,n) for(ll i=0;i<n;i++)
#define f1(i,n) for(ll i=1;i<=n;i++)
#define   crap ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0)
using namespace std;
#define INF 1000000
#define vll vector<ll>
const int M = 1e9+7;
ll fastpower(ll x,ll n,ll M)
{
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return fastpower((x*x)%M,n/2,M);
    else                             //n is odd
        return (x*fastpower((x*x)%M,(n-1)/2,M))%M;
}
ll GCD(ll A, ll B) {
    if(B==0)
        return A;
    else
        return GCD(B, A % B);
}
bool vowl(char c)
{
  return c=='a'||c=='e'||c=='i'||c=='o'||c=='u';
}
ll modInverse(ll A,ll M)// when M is prime
{
    return fastpower(A,M-2,M);
}
void sieve(ll N) {
        bool isPrime[N+1];
        for(ll i = 0; i <= N;++i) {
            isPrime[i] = true;
        }
        isPrime[0] = false;
        isPrime[1] = false;
        for(ll i = 2; i * i <= N; ++i) {
             if(isPrime[i] == true) {                    //Mark all the multiples of i as composite numbers
                 for(ll j = i * i; j <= N ;j += i)
                     isPrime[j] = false;
            }
        }
    }
vector<ll> factorize(ll n) {
    vector<ll> res;
    for (ll i = 2; i * i <= n; ++i) {
        while (n % i == 0) {
            res.push_back(i);
            n /= i;
        }
    }
    if (n != 1) {
        res.push_back(n);
    }
    return res;
}

int main()
{
	crap;
	#ifndef ONLINE_JUDGE
	    freopen("input.txt","r",stdin);
	    freopen("output.txt","w",stdout);
	    #endif
	ll n,k;
	cin>>n>>k;
	ll t=1;

	ll h=(k*8)/n;
	while(h--)
	{
t*=2;
if(t>=n)
break;

	}
	map<ll,ll>m;
	f(i,n)
	{
		ll y;
		cin>>y;

m[y]++;

	}
	vll v;

	for(auto it=m.begin();it!=m.end();it++)
	{
v.pb(it->second);

	}

	if(t>=v.size())
		cout<<"0"<<endl;
	else
	{ll d=1000000000;
		for(int i=0;i+t<=v.size();i++)
		{
			ll cont=0;

			for(int j=i;j<=(i+t)-1;j++)
			{
cont+=v[i];

			}
			d=min(d,n-cont);

		}
		cout<<d<<endl;

	}
	return 0;
}


#include<iostream>
#include<bits/stdc++.h>
#define m_p make_pair
#define fi first
#define se second
#define pb push_back
typedef long long ll;
#define f(i,n) for(ll i=0;i<n;i++)
#define f1(i,n) for(ll i=1;i<=n;i++)
#define   crap ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0)
using namespace std;
#define INF 1000000
#define vll vector<ll>
const int M = 1e9+7;
ll fastpower(ll x,ll n,ll M)
{
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return fastpower((x*x)%M,n/2,M);
    else                             //n is odd
        return (x*fastpower((x*x)%M,(n-1)/2,M))%M;
}
ll GCD(ll A, ll B) {
    if(B==0)
        return A;
    else
        return GCD(B, A % B);
}
bool vowl(char c)
{
  return c=='a'||c=='e'||c=='i'||c=='o'||c=='u';
}
ll modInverse(ll A,ll M)// when M is prime
{
    return fastpower(A,M-2,M);
}
void sieve(ll N) {
        bool isPrime[N+1];
        for(ll i = 0; i <= N;++i) {
            isPrime[i] = true;
        }
        isPrime[0] = false;
        isPrime[1] = false;
        for(ll i = 2; i * i <= N; ++i) {
             if(isPrime[i] == true) {                    //Mark all the multiples of i as composite numbers
                 for(ll j = i * i; j <= N ;j += i)
                     isPrime[j] = false;
            }
        }
    }
vector<ll> factorize(ll n) {
    vector<ll> res;
    for (ll i = 2; i * i <= n; ++i) {
        while (n % i == 0) {
            res.push_back(i);
            n /= i;
        }
    }
    if (n != 1) {
        res.push_back(n);
    }
    return res;
}

int main()
{
	crap;
	#ifndef ONLINE_JUDGE
	    freopen("input.txt","r",stdin);
	    freopen("output.txt","w",stdout);
	    #endif
	ll n,k;
	cin>>n>>k;
	ll t=1;

	int h=(k*8)/n;
	for(int i=0;i<min(20,h);i++)
	{
t*=2;

	}

	map<ll,ll>m;
	f(i,n)
	{
		ll y;
		cin>>y;

m[y]++;

	}
	vll v;

	for(auto it=m.begin();it!=m.end();it++)
	{
v.pb(it->second);

	}

	if(t>=v.size())
		cout<<"0"<<endl;
	else
	{
		ll d=INT_MAX;
		for(long long int i=0;i+t<=v.size();i++)
		{
			ll cont=0;

			for(long long int j=i;j<(i+t);j++)
			{
cont+=v[i];

			}
			d=min(d,n-cont);

		}
		cout<<d<<endl;

	}
	return 0;
}


#include<iostream>
#include<bits/stdc++.h>
#define m_p make_pair
#define fi first
#define se second
#define pb push_back
typedef long long ll;
#define f(i,n) for(ll i=0;i<n;i++)
#define f1(i,n) for(ll i=1;i<=n;i++)
#define   crap ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0)
using namespace std;
#define INF 1000000
#define vll vector<ll>
const int M = 1e9+7;
ll fastpower(ll x,ll n,ll M)
{
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return fastpower((x*x)%M,n/2,M);
    else                             //n is odd
        return (x*fastpower((x*x)%M,(n-1)/2,M))%M;
}
ll GCD(ll A, ll B) {
    if(B==0)
        return A;
    else
        return GCD(B, A % B);
}
bool vowl(char c)
{
  return c=='a'||c=='e'||c=='i'||c=='o'||c=='u';
}
ll modInverse(ll A,ll M)// when M is prime
{
    return fastpower(A,M-2,M);
}
void sieve(ll N) {
        bool isPrime[N+1];
        for(ll i = 0; i <= N;++i) {
            isPrime[i] = true;
        }
        isPrime[0] = false;
        isPrime[1] = false;
        for(ll i = 2; i * i <= N; ++i) {
             if(isPrime[i] == true) {                    //Mark all the multiples of i as composite numbers
                 for(ll j = i * i; j <= N ;j += i)
                     isPrime[j] = false;
            }
        }
    }
vector<ll> factorize(ll n) {
    vector<ll> res;
    for (ll i = 2; i * i <= n; ++i) {
        while (n % i == 0) {
            res.push_back(i);
            n /= i;
        }
    }
    if (n != 1) {
        res.push_back(n);
    }
    return res;
}

int main()
{
	crap;
	#ifndef ONLINE_JUDGE
	    freopen("input.txt","r",stdin);
	    freopen("output.txt","w",stdout);
	    #endif
	ll n,k;
	cin>>n>>k;
	ll t=1;

	int h=(k*8)/n;
	for(int i=0;i<min(20,h);i++)
	{
t*=2;

	}

	map<ll,ll>m;
	f(i,n)
	{
		ll y;
		cin>>y;

m[y]++;

	}
	vll v;

	for(auto it=m.begin();it!=m.end();it++)
	{
v.pb(it->second);

	}

	if(t>=v.size())
		cout<<"0"<<endl;
	else
	{
		ll d=INT_MAX;
		for(long long int i=0;(i+t)<=v.size();i++)
		{
			ll cont=0;

			for(long long int j=i;j<(i+t);j++)
			{
cont+=v[j];

			}
			d=min(d,n-cont);

		}
		cout<<d<<endl;

	}
	return 0;
}


/*      ###########################
        #  Author : Pranay Garg   #
        #  College : SGSITS       #
        ###########################
*/
#include<bits/stdc++.h>
#define ll long long int
#define ironman ios_base::sync_with_stdio(false);cin.tie(NULL);
#define MOD 1000000007
#define endl '\n'
#define INF 1e18L+1
#define mp make_pair
#define pb push_back
#define debug1(x) cout<<#x<<" "<<x<<endl;
#define debug2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<endl;
using namespace std;
template<class T> T max(T a, T b, T c) {
    return max(a, max(b, c));
}
template<class T> T min(T a, T b, T c) {
    return min(a, min(b, c));
}
void fastio()
{
    ironman
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
            freopen("error.txt","w",stderr);
    #endif
}
bool prime[100005];
void SieveOfEratosthenes(ll n)//O(nloglogn)
{
    memset(prime, true, sizeof(prime));

    for (ll p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
            for (ll i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }
}
bool isPrime(ll n)//O(sqrt(n))
{
    if(n<2)
        return false;
    for(ll i=2;i*i<=n;i++)
        if(n%i==0)
            return false;
    return true;
}
std::vector<ll> factors(ll n)//O(sqrt(n))
{
    std::vector<ll> f;
    for(ll i=2;i*i<=n;i++)
    {
        while(n%i==0)
        {
            f.push_back(i);
            n = n/i;
        }
    }
    if(n>1) f.push_back(n);
    return f;
}
ll gcd(ll a,ll b)//O(logn)
{
    if(!b) return a;
    return gcd(b,a%b);
}
ll modpow(ll x,ll n,ll m)//O(logn)// used for calculating (x^n)%m
{
    if(n==0) return 1%m;
    ll u = modpow(x,n/2,m);
    u = (u%m * u%m)%m;
    if(n%2==1)
        u = (u%m * x%m)%m;
    return u%m;
}
ll eulerstotientfunction(ll n)//O(sqrt(n))
{
    ll ans = n;
    for(ll i=2;i*i<=n;i++)
    {
        if(n%i==0)
        {
            while(n%i==0)
                n = n/i;
            ans -= ans/i;
        }
    }
    if(n>1)
        ans -= ans/n;
    return ans;
}
ll modinverse(ll x,ll m)//O(logn)
{
    ll temp = eulerstotientfunction(m);
    return modpow(x,temp-1,m);
}
ll ncr(ll n,ll k)
{
    ll res = 1;
    k = min(k,n-k);
    for(ll i=0;i<k;i++)
    {
        res *= (n-i);
        res /= (i+1);
    }
    return res;
}
int main()
{
    fastio();
    ll n,s;
    cin >> n >> s;
    std::vector<ll> arr(n),count;
    ll unique = 0;
    unordered_map<ll,ll> mp;
    for(ll i=0;i<n;i++)
    {
        cin >> arr[i];
        mp[arr[i]]++;
        if(mp[arr[i]]==1)
            unique++;
    }
    s = s*8;
    ll currsize = n*ceil(log2(unique));
    if(currsize<=s)
    {
        cout << 0 << endl;
        return 0;
    }
    s = s/n;
    s = (1LL<<s);
    for(auto it=mp.begin();it!=mp.end();it++)
        count.pb(it->second);
    sort(count.begin(), count.end());
    ll pref[unique];
    memset(pref,0,sizeof(pref));
    pref[0] = count[0];
    for(ll i=1;i<unique;i++)
    {
        pref[i] = count[i]+pref[i-1];
    }
    ll ans = pref[unique-1]-pref[s-1];
    for(ll i=1,j=i+s-1;i<unique && j<unique;i++,j++)
    {
        ans = min(ans,ans+count[i-1]-count[j]);
    }
    cout << ans << endl;
}


/*      ###########################
        #  Author : Pranay Garg   #
        #  College : SGSITS       #
        ###########################
*/
#include<bits/stdc++.h>
#define ll long long int
#define ironman ios_base::sync_with_stdio(false);cin.tie(NULL);
#define MOD 1000000007
#define endl '\n'
#define INF 1e18L+1
#define mp make_pair
#define pb push_back
#define debug1(x) cout<<#x<<" "<<x<<endl;
#define debug2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<endl;
using namespace std;
template<class T> T max(T a, T b, T c) {
    return max(a, max(b, c));
}
template<class T> T min(T a, T b, T c) {
    return min(a, min(b, c));
}
void fastio()
{
    ironman
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
            freopen("error.txt","w",stderr);
    #endif
}
bool prime[100005];
void SieveOfEratosthenes(ll n)//O(nloglogn)
{
    memset(prime, true, sizeof(prime));

    for (ll p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
            for (ll i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }
}
bool isPrime(ll n)//O(sqrt(n))
{
    if(n<2)
        return false;
    for(ll i=2;i*i<=n;i++)
        if(n%i==0)
            return false;
    return true;
}
std::vector<ll> factors(ll n)//O(sqrt(n))
{
    std::vector<ll> f;
    for(ll i=2;i*i<=n;i++)
    {
        while(n%i==0)
        {
            f.push_back(i);
            n = n/i;
        }
    }
    if(n>1) f.push_back(n);
    return f;
}
ll gcd(ll a,ll b)//O(logn)
{
    if(!b) return a;
    return gcd(b,a%b);
}
ll modpow(ll x,ll n,ll m)//O(logn)// used for calculating (x^n)%m
{
    if(n==0) return 1%m;
    ll u = modpow(x,n/2,m);
    u = (u%m * u%m)%m;
    if(n%2==1)
        u = (u%m * x%m)%m;
    return u%m;
}
ll eulerstotientfunction(ll n)//O(sqrt(n))
{
    ll ans = n;
    for(ll i=2;i*i<=n;i++)
    {
        if(n%i==0)
        {
            while(n%i==0)
                n = n/i;
            ans -= ans/i;
        }
    }
    if(n>1)
        ans -= ans/n;
    return ans;
}
ll modinverse(ll x,ll m)//O(logn)
{
    ll temp = eulerstotientfunction(m);
    return modpow(x,temp-1,m);
}
ll ncr(ll n,ll k)
{
    ll res = 1;
    k = min(k,n-k);
    for(ll i=0;i<k;i++)
    {
        res *= (n-i);
        res /= (i+1);
    }
    return res;
}
int main()
{
    fastio();
    ll n,s;
    cin >> n >> s;
    std::vector<ll> arr(n),count;
    ll unique = 0;
    unordered_map<ll,ll> mp;
    for(ll i=0;i<n;i++)
    {
        cin >> arr[i];
        mp[arr[i]]++;
        if(mp[arr[i]]==1)
            unique++;
    }
    s = (s*8)/n;
    s = (1LL<<s);
    if(s>=unique)
    {
        cout << 0 << endl;
        return 0;
    }
    for(auto it:mp)
        count.pb(it.second);
    //sort(count.begin(), count.end());
    ll ans = INF,temp = 0;
    for(ll i=0;i<min(unique,s);i++)
        temp+=count[i];
    ans = min(ans,n-temp);
    for(ll i=min(unique,s);i<unique;i++)
    {
        temp+=count[i];
        temp-=count[i-s];
        ans = min(ans,n-temp);
    }
    cout << ans << endl;
}


/*      ###########################
        #  Author : Pranay Garg   #
        #  College : SGSITS       #
        ###########################
*/
#include<bits/stdc++.h>
#define ll long long int
#define ironman ios_base::sync_with_stdio(false);cin.tie(NULL);
#define MOD 1000000007
#define endl '\n'
#define INF 1e18L+1
#define mp make_pair
#define pb push_back
#define debug1(x) cout<<#x<<" "<<x<<endl;
#define debug2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<endl;
using namespace std;
template<class T> T max(T a, T b, T c) {
    return max(a, max(b, c));
}
template<class T> T min(T a, T b, T c) {
    return min(a, min(b, c));
}
void fastio()
{
    ironman
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
            freopen("error.txt","w",stderr);
    #endif
}
bool prime[100005];
void SieveOfEratosthenes(ll n)//O(nloglogn)
{
    memset(prime, true, sizeof(prime));

    for (ll p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
            for (ll i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }
}
bool isPrime(ll n)//O(sqrt(n))
{
    if(n<2)
        return false;
    for(ll i=2;i*i<=n;i++)
        if(n%i==0)
            return false;
    return true;
}
std::vector<ll> factors(ll n)//O(sqrt(n))
{
    std::vector<ll> f;
    for(ll i=2;i*i<=n;i++)
    {
        while(n%i==0)
        {
            f.push_back(i);
            n = n/i;
        }
    }
    if(n>1) f.push_back(n);
    return f;
}
ll gcd(ll a,ll b)//O(logn)
{
    if(!b) return a;
    return gcd(b,a%b);
}
ll modpow(ll x,ll n,ll m)//O(logn)// used for calculating (x^n)%m
{
    if(n==0) return 1%m;
    ll u = modpow(x,n/2,m);
    u = (u%m * u%m)%m;
    if(n%2==1)
        u = (u%m * x%m)%m;
    return u%m;
}
ll eulerstotientfunction(ll n)//O(sqrt(n))
{
    ll ans = n;
    for(ll i=2;i*i<=n;i++)
    {
        if(n%i==0)
        {
            while(n%i==0)
                n = n/i;
            ans -= ans/i;
        }
    }
    if(n>1)
        ans -= ans/n;
    return ans;
}
ll modinverse(ll x,ll m)//O(logn)
{
    ll temp = eulerstotientfunction(m);
    return modpow(x,temp-1,m);
}
ll ncr(ll n,ll k)
{
    ll res = 1;
    k = min(k,n-k);
    for(ll i=0;i<k;i++)
    {
        res *= (n-i);
        res /= (i+1);
    }
    return res;
}
int main()
{
    fastio();
    ll n,s;
    cin >> n >> s;
    std::vector<ll> arr(n),count;
    ll unique = 0;
    unordered_map<ll,ll> mp;
    for(ll i=0;i<n;i++)
    {
        cin >> arr[i];
        mp[arr[i]]++;
        if(mp[arr[i]]==1)
            unique++;
    }
    s = (s*8)/n;
    s = (1LL<<s);
    if(s>=unique)
    {
        cout << 0 << endl;
        return 0;
    }
    for(auto it:mp)
        count.pb(it.second);
    sort(count.begin(), count.end());
    ll ans = 0;
    for(ll i=0;i<min(unique,s);i++)
        ans+=count[i];
    ans = min(ans,n-ans);
    for(ll i=min(unique,s);i<unique;i++)
    {
        ll temp = ans;
        temp+=count[i]-count[i-s];
        ans = min(ans,n-temp);
    }
    cout << ans << endl;
}


/*      ###########################
        #  Author : Pranay Garg   #
        #  College : SGSITS       #
        ###########################
*/
#include<bits/stdc++.h>
#define ll long long int
#define ironman ios_base::sync_with_stdio(false);cin.tie(NULL);
#define MOD 1000000007
#define endl '\n'
#define INF 1e18L+1
#define mp make_pair
#define pb push_back
#define debug1(x) cout<<#x<<" "<<x<<endl;
#define debug2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<endl;
using namespace std;
template<class T> T max(T a, T b, T c) {
    return max(a, max(b, c));
}
template<class T> T min(T a, T b, T c) {
    return min(a, min(b, c));
}
void fastio()
{
    ironman
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
            freopen("error.txt","w",stderr);
    #endif
}
bool prime[100005];
void SieveOfEratosthenes(ll n)//O(nloglogn)
{
    memset(prime, true, sizeof(prime));

    for (ll p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
            for (ll i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }
}
bool isPrime(ll n)//O(sqrt(n))
{
    if(n<2)
        return false;
    for(ll i=2;i*i<=n;i++)
        if(n%i==0)
            return false;
    return true;
}
std::vector<ll> factors(ll n)//O(sqrt(n))
{
    std::vector<ll> f;
    for(ll i=2;i*i<=n;i++)
    {
        while(n%i==0)
        {
            f.push_back(i);
            n = n/i;
        }
    }
    if(n>1) f.push_back(n);
    return f;
}
ll gcd(ll a,ll b)//O(logn)
{
    if(!b) return a;
    return gcd(b,a%b);
}
ll modpow(ll x,ll n,ll m)//O(logn)// used for calculating (x^n)%m
{
    if(n==0) return 1%m;
    ll u = modpow(x,n/2,m);
    u = (u%m * u%m)%m;
    if(n%2==1)
        u = (u%m * x%m)%m;
    return u%m;
}
ll eulerstotientfunction(ll n)//O(sqrt(n))
{
    ll ans = n;
    for(ll i=2;i*i<=n;i++)
    {
        if(n%i==0)
        {
            while(n%i==0)
                n = n/i;
            ans -= ans/i;
        }
    }
    if(n>1)
        ans -= ans/n;
    return ans;
}
ll modinverse(ll x,ll m)//O(logn)
{
    ll temp = eulerstotientfunction(m);
    return modpow(x,temp-1,m);
}
ll ncr(ll n,ll k)
{
    ll res = 1;
    k = min(k,n-k);
    for(ll i=0;i<k;i++)
    {
        res *= (n-i);
        res /= (i+1);
    }
    return res;
}
int main()
{
    fastio();
    ll n,s;
    cin >> n >> s;
    std::vector<ll> arr(n),count;
    ll unique = 0;
    unordered_map<ll,ll> mp;
    for(ll i=0;i<n;i++)
    {
        cin >> arr[i];
        mp[arr[i]]++;
        if(mp[arr[i]]==1)
            unique++;
    }
    s = (s*8)/n;
    s = (1LL<<s);
    if(s>=unique)
    {
        cout << 0 << endl;
        return 0;
    }
    for(auto it:mp)
        count.pb(it.second);
    sort(count.begin(), count.end());
    ll ans = INF,temp = 0;
    for(ll i=0;i<min(unique,s);i++)
        temp+=count[i];
    ans = min(ans,n-temp);
    for(ll i=min(unique,s);i<unique;i++)
    {
        temp+=count[i]-count[i-s];
        ans = min(ans,n-temp);
    }
    cout << ans << endl;
}


/*      ###########################
        #  Author : Pranay Garg   #
        #  College : SGSITS       #
        ###########################
*/
#include<bits/stdc++.h>
#define ll long long int
#define ironman ios_base::sync_with_stdio(false);cin.tie(NULL);
#define MOD 1000000007
#define endl '\n'
#define INF 1e18L+1
#define mp make_pair
#define pb push_back
#define debug1(x) cout<<#x<<" "<<x<<endl;
#define debug2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<endl;
using namespace std;
template<class T> T max(T a, T b, T c) {
    return max(a, max(b, c));
}
template<class T> T min(T a, T b, T c) {
    return min(a, min(b, c));
}
void fastio()
{
    ironman
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
            freopen("error.txt","w",stderr);
    #endif
}
bool prime[100005];
void SieveOfEratosthenes(ll n)//O(nloglogn)
{
    memset(prime, true, sizeof(prime));

    for (ll p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
            for (ll i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }
}
bool isPrime(ll n)//O(sqrt(n))
{
    if(n<2)
        return false;
    for(ll i=2;i*i<=n;i++)
        if(n%i==0)
            return false;
    return true;
}
std::vector<ll> factors(ll n)//O(sqrt(n))
{
    std::vector<ll> f;
    for(ll i=2;i*i<=n;i++)
    {
        while(n%i==0)
        {
            f.push_back(i);
            n = n/i;
        }
    }
    if(n>1) f.push_back(n);
    return f;
}
ll gcd(ll a,ll b)//O(logn)
{
    if(!b) return a;
    return gcd(b,a%b);
}
ll modpow(ll x,ll n,ll m)//O(logn)// used for calculating (x^n)%m
{
    if(n==0) return 1%m;
    ll u = modpow(x,n/2,m);
    u = (u%m * u%m)%m;
    if(n%2==1)
        u = (u%m * x%m)%m;
    return u%m;
}
ll eulerstotientfunction(ll n)//O(sqrt(n))
{
    ll ans = n;
    for(ll i=2;i*i<=n;i++)
    {
        if(n%i==0)
        {
            while(n%i==0)
                n = n/i;
            ans -= ans/i;
        }
    }
    if(n>1)
        ans -= ans/n;
    return ans;
}
ll modinverse(ll x,ll m)//O(logn)
{
    ll temp = eulerstotientfunction(m);
    return modpow(x,temp-1,m);
}
ll ncr(ll n,ll k)
{
    ll res = 1;
    k = min(k,n-k);
    for(ll i=0;i<k;i++)
    {
        res *= (n-i);
        res /= (i+1);
    }
    return res;
}
int main()
{
    fastio();
    ll n,s;
    cin >> n >> s;
    std::vector<ll> arr(n),count;
    ll unique = 0;
    unordered_map<ll,ll> mp;
    for(ll i=0;i<n;i++)
    {
        cin >> arr[i];
        mp[arr[i]]++;
        if(mp[arr[i]]==1)
            unique++;
    }
    s = (s*8)/n;
    s = (1LL<<s);
    if(s>=unique)
    {
        cout << 0 << endl;
        return 0;
    }
    for(auto it:mp)
        count.pb(it.second);
    sort(count.begin(), count.end());
    ll ans = INF,temp = 0;
    for(ll i=0;i<min(unique,s);i++)
        temp+=count[i];
    ans = min(ans,n-temp);
    for(ll i=min(unique,s);i<unique;i++)
    {
        temp+=count[i];
        temp-=count[i-s];
        ans = min(ans,n-temp);
    }
    cout << ans << endl;
}


/*      ###########################
        #  Author : Pranay Garg   #
        #  College : SGSITS       #
        ###########################
*/
#include<bits/stdc++.h>
#define ll long long int
#define ironman ios_base::sync_with_stdio(false);cin.tie(NULL);
#define MOD 1000000007
#define endl '\n'
#define INF 1e18L+1
#define mp make_pair
#define pb push_back
#define debug1(x) cout<<#x<<" "<<x<<endl;
#define debug2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<endl;
using namespace std;
template<class T> T max(T a, T b, T c) {
    return max(a, max(b, c));
}
template<class T> T min(T a, T b, T c) {
    return min(a, min(b, c));
}
void fastio()
{
    ironman
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
            freopen("error.txt","w",stderr);
    #endif
}
bool prime[100005];
void SieveOfEratosthenes(ll n)//O(nloglogn)
{
    memset(prime, true, sizeof(prime));

    for (ll p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
            for (ll i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }
}
bool isPrime(ll n)//O(sqrt(n))
{
    if(n<2)
        return false;
    for(ll i=2;i*i<=n;i++)
        if(n%i==0)
            return false;
    return true;
}
std::vector<ll> factors(ll n)//O(sqrt(n))
{
    std::vector<ll> f;
    for(ll i=2;i*i<=n;i++)
    {
        while(n%i==0)
        {
            f.push_back(i);
            n = n/i;
        }
    }
    if(n>1) f.push_back(n);
    return f;
}
ll gcd(ll a,ll b)//O(logn)
{
    if(!b) return a;
    return gcd(b,a%b);
}
ll modpow(ll x,ll n,ll m)//O(logn)// used for calculating (x^n)%m
{
    if(n==0) return 1%m;
    ll u = modpow(x,n/2,m);
    u = (u%m * u%m)%m;
    if(n%2==1)
        u = (u%m * x%m)%m;
    return u%m;
}
ll eulerstotientfunction(ll n)//O(sqrt(n))
{
    ll ans = n;
    for(ll i=2;i*i<=n;i++)
    {
        if(n%i==0)
        {
            while(n%i==0)
                n = n/i;
            ans -= ans/i;
        }
    }
    if(n>1)
        ans -= ans/n;
    return ans;
}
ll modinverse(ll x,ll m)//O(logn)
{
    ll temp = eulerstotientfunction(m);
    return modpow(x,temp-1,m);
}
ll ncr(ll n,ll k)
{
    ll res = 1;
    k = min(k,n-k);
    for(ll i=0;i<k;i++)
    {
        res *= (n-i);
        res /= (i+1);
    }
    return res;
}
int main()
{
    fastio();
    ll n,s;
    cin >> n >> s;
    std::vector<ll> arr(n),count;
    unordered_set<ll> st;
    unordered_map<ll,ll> mp;
    for(ll i=0;i<n;i++)
    {
        cin >> arr[i];
        mp[arr[i]]++;
        st.insert(arr[i]);
    }
    s = s*8;
    ll currsize = n*(ll)ceil(log2(st.size()));
    if(currsize<=s)
    {
        cout << 0 << endl;
        return 0;
    }
    s = s/n;
    s = (1<<s);
    s = st.size()-s;
    //st.clear();
    multiset<ll> sttt;
    for(auto it=mp.begin();it!=mp.end();it++)
    {
        sttt.insert(it->second);
    }
    ll ans = 0;
    //cout << s << endl;
    for(auto it=sttt.begin();it!=sttt.end() && s>0;it++)
    {
        //cout << *it << endl;
        ans+=*it;
        s--;
    }
    cout << ans << endl;
}


/*      ###########################
        #  Author : Pranay Garg   #
        #  College : SGSITS       #
        ###########################
*/
#include<bits/stdc++.h>
#define ll long long int
#define ironman ios_base::sync_with_stdio(false);cin.tie(NULL);
#define MOD 1000000007
#define endl '\n'
#define INF 1e18L+1
#define mp make_pair
#define pb push_back
#define debug1(x) cout<<#x<<" "<<x<<endl;
#define debug2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<endl;
using namespace std;
template<class T> T max(T a, T b, T c) {
    return max(a, max(b, c));
}
template<class T> T min(T a, T b, T c) {
    return min(a, min(b, c));
}
void fastio()
{
    ironman
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
            freopen("error.txt","w",stderr);
    #endif
}
bool prime[100005];
void SieveOfEratosthenes(ll n)//O(nloglogn)
{
    memset(prime, true, sizeof(prime));

    for (ll p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
            for (ll i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }
}
bool isPrime(ll n)//O(sqrt(n))
{
    if(n<2)
        return false;
    for(ll i=2;i*i<=n;i++)
        if(n%i==0)
            return false;
    return true;
}
std::vector<ll> factors(ll n)//O(sqrt(n))
{
    std::vector<ll> f;
    for(ll i=2;i*i<=n;i++)
    {
        while(n%i==0)
        {
            f.push_back(i);
            n = n/i;
        }
    }
    if(n>1) f.push_back(n);
    return f;
}
ll gcd(ll a,ll b)//O(logn)
{
    if(!b) return a;
    return gcd(b,a%b);
}
ll modpow(ll x,ll n,ll m)//O(logn)// used for calculating (x^n)%m
{
    if(n==0) return 1%m;
    ll u = modpow(x,n/2,m);
    u = (u%m * u%m)%m;
    if(n%2==1)
        u = (u%m * x%m)%m;
    return u%m;
}
ll eulerstotientfunction(ll n)//O(sqrt(n))
{
    ll ans = n;
    for(ll i=2;i*i<=n;i++)
    {
        if(n%i==0)
        {
            while(n%i==0)
                n = n/i;
            ans -= ans/i;
        }
    }
    if(n>1)
        ans -= ans/n;
    return ans;
}
ll modinverse(ll x,ll m)//O(logn)
{
    ll temp = eulerstotientfunction(m);
    return modpow(x,temp-1,m);
}
ll ncr(ll n,ll k)
{
    ll res = 1;
    k = min(k,n-k);
    for(ll i=0;i<k;i++)
    {
        res *= (n-i);
        res /= (i+1);
    }
    return res;
}
int main()
{
    fastio();
    ll n,s;
    cin >> n >> s;
    std::vector<ll> arr(n),count;
    ll unique = 0;
    map<ll,ll> mp;
    for(ll i=0;i<n;i++)
    {
        cin >> arr[i];
        mp[arr[i]]++;
        if(mp[arr[i]]==1)
            unique++;
    }
    s = (s*8)/n;
    s = (1LL<<s);
    if(s>=unique)
    {
        cout << 0 << endl;
        return 0;
    }
    for(auto it:mp)
        count.pb(it.second);
    //sort(count.begin(), count.end());
    ll ans = INF,temp = 0;
    for(ll i=0;i<min(unique,s);i++)
        temp+=count[i];
    ans = min(ans,n-temp);
    for(ll i=min(unique,s);i<unique;i++)
    {
        temp+=count[i];
        temp-=count[i-s];
        ans = min(ans,n-temp);
    }
    cout << ans << endl;
}


/*      ###########################
        #  Author : Pranay Garg   #
        #  College : SGSITS       #
        ###########################
*/
#include<bits/stdc++.h>
#define ll long long int
#define ironman ios_base::sync_with_stdio(false);cin.tie(NULL);
#define MOD 1000000007
#define endl '\n'
#define INF 1e18L+1
#define mp make_pair
#define pb push_back
#define debug1(x) cout<<#x<<" "<<x<<endl;
#define debug2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<endl;
using namespace std;
template<class T> T max(T a, T b, T c) {
    return max(a, max(b, c));
}
template<class T> T min(T a, T b, T c) {
    return min(a, min(b, c));
}
void fastio()
{
    ironman
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
            freopen("error.txt","w",stderr);
    #endif
}
bool prime[100005];
void SieveOfEratosthenes(ll n)//O(nloglogn)
{
    memset(prime, true, sizeof(prime));

    for (ll p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
            for (ll i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }
}
bool isPrime(ll n)//O(sqrt(n))
{
    if(n<2)
        return false;
    for(ll i=2;i*i<=n;i++)
        if(n%i==0)
            return false;
    return true;
}
std::vector<ll> factors(ll n)//O(sqrt(n))
{
    std::vector<ll> f;
    for(ll i=2;i*i<=n;i++)
    {
        while(n%i==0)
        {
            f.push_back(i);
            n = n/i;
        }
    }
    if(n>1) f.push_back(n);
    return f;
}
ll gcd(ll a,ll b)//O(logn)
{
    if(!b) return a;
    return gcd(b,a%b);
}
ll modpow(ll x,ll n,ll m)//O(logn)// used for calculating (x^n)%m
{
    if(n==0) return 1%m;
    ll u = modpow(x,n/2,m);
    u = (u%m * u%m)%m;
    if(n%2==1)
        u = (u%m * x%m)%m;
    return u%m;
}
ll eulerstotientfunction(ll n)//O(sqrt(n))
{
    ll ans = n;
    for(ll i=2;i*i<=n;i++)
    {
        if(n%i==0)
        {
            while(n%i==0)
                n = n/i;
            ans -= ans/i;
        }
    }
    if(n>1)
        ans -= ans/n;
    return ans;
}
ll modinverse(ll x,ll m)//O(logn)
{
    ll temp = eulerstotientfunction(m);
    return modpow(x,temp-1,m);
}
ll ncr(ll n,ll k)
{
    ll res = 1;
    k = min(k,n-k);
    for(ll i=0;i<k;i++)
    {
        res *= (n-i);
        res /= (i+1);
    }
    return res;
}
int main()
{
    fastio();
    ll n,s;
    cin >> n >> s;
    std::vector<ll> arr(n),count;
    ll unique = 0;
    unordered_map<ll,ll> mp;
    for(ll i=0;i<n;i++)
    {
        cin >> arr[i];
        mp[arr[i]]++;
        if(mp[arr[i]]==1)
            unique++;
    }
    s = (s*8)/n;
    s = (1LL<<s);
    if(s>=unique)
    {
        cout << 0 << endl;
        return 0;
    }
    for(auto it:mp)
        count.pb(it.second);
    sort(count.begin(), count.end());
    ll ans = 0;
    for(ll i=unique-s;i<unique;i++)
        ans+=count[i];
    ans = n-ans;
    cout << ans << endl;
}


/*      ###########################
        #  Author : Pranay Garg   #
        #  College : SGSITS       #
        ###########################
*/
#include<bits/stdc++.h>
#define ll long long int
#define ironman ios_base::sync_with_stdio(false);cin.tie(NULL);
#define MOD 1000000007
#define endl '\n'
#define INF 1e18L+1
#define mp make_pair
#define pb push_back
#define debug1(x) cout<<#x<<" "<<x<<endl;
#define debug2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<endl;
using namespace std;
template<class T> T max(T a, T b, T c) {
    return max(a, max(b, c));
}
template<class T> T min(T a, T b, T c) {
    return min(a, min(b, c));
}
void fastio()
{
    ironman
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
            freopen("error.txt","w",stderr);
    #endif
}
bool prime[100005];
void SieveOfEratosthenes(ll n)//O(nloglogn)
{
    memset(prime, true, sizeof(prime));

    for (ll p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
            for (ll i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }
}
bool isPrime(ll n)//O(sqrt(n))
{
    if(n<2)
        return false;
    for(ll i=2;i*i<=n;i++)
        if(n%i==0)
            return false;
    return true;
}
std::vector<ll> factors(ll n)//O(sqrt(n))
{
    std::vector<ll> f;
    for(ll i=2;i*i<=n;i++)
    {
        while(n%i==0)
        {
            f.push_back(i);
            n = n/i;
        }
    }
    if(n>1) f.push_back(n);
    return f;
}
ll gcd(ll a,ll b)//O(logn)
{
    if(!b) return a;
    return gcd(b,a%b);
}
ll modpow(ll x,ll n,ll m)//O(logn)// used for calculating (x^n)%m
{
    if(n==0) return 1%m;
    ll u = modpow(x,n/2,m);
    u = (u%m * u%m)%m;
    if(n%2==1)
        u = (u%m * x%m)%m;
    return u%m;
}
ll eulerstotientfunction(ll n)//O(sqrt(n))
{
    ll ans = n;
    for(ll i=2;i*i<=n;i++)
    {
        if(n%i==0)
        {
            while(n%i==0)
                n = n/i;
            ans -= ans/i;
        }
    }
    if(n>1)
        ans -= ans/n;
    return ans;
}
ll modinverse(ll x,ll m)//O(logn)
{
    ll temp = eulerstotientfunction(m);
    return modpow(x,temp-1,m);
}
ll ncr(ll n,ll k)
{
    ll res = 1;
    k = min(k,n-k);
    for(ll i=0;i<k;i++)
    {
        res *= (n-i);
        res /= (i+1);
    }
    return res;
}
int main()
{
    fastio();
    ll n,s;
    cin >> n >> s;
    std::vector<ll> arr(n),count;
    ll unique = 0;
    unordered_map<ll,ll> mp;
    for(ll i=0;i<n;i++)
    {
        cin >> arr[i];
        mp[arr[i]]++;
        if(mp[arr[i]]==1)
            unique++;
    }
    s = (s*8)/n;
    s = min(s,21LL);
    s = (1LL<<s);
    if(s>=unique)
    {
        cout << 0 << endl;
        return 0;
    }
    for(auto it:mp)
        count.pb(it.second);
    sort(count.begin(), count.end());
    ll ans = 0;
    for(ll i=unique-s;i<unique;i++)
        ans+=count[i];
    ans = n-ans;
    cout << ans << endl;
}


/*      ###########################
        #  Author : Pranay Garg   #
        #  College : SGSITS       #
        ###########################
*/
#include<bits/stdc++.h>
#define ll long long int
#define ironman ios_base::sync_with_stdio(false);cin.tie(NULL);
#define MOD 1000000007
#define endl '\n'
#define INF 1e18L+1
#define mp make_pair
#define pb push_back
#define debug1(x) cout<<#x<<" "<<x<<endl;
#define debug2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<endl;
using namespace std;
template<class T> T max(T a, T b, T c) {
    return max(a, max(b, c));
}
template<class T> T min(T a, T b, T c) {
    return min(a, min(b, c));
}
void fastio()
{
    ironman
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
            freopen("error.txt","w",stderr);
    #endif
}
bool prime[100005];
void SieveOfEratosthenes(ll n)//O(nloglogn)
{
    memset(prime, true, sizeof(prime));

    for (ll p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
            for (ll i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }
}
bool isPrime(ll n)//O(sqrt(n))
{
    if(n<2)
        return false;
    for(ll i=2;i*i<=n;i++)
        if(n%i==0)
            return false;
    return true;
}
std::vector<ll> factors(ll n)//O(sqrt(n))
{
    std::vector<ll> f;
    for(ll i=2;i*i<=n;i++)
    {
        while(n%i==0)
        {
            f.push_back(i);
            n = n/i;
        }
    }
    if(n>1) f.push_back(n);
    return f;
}
ll gcd(ll a,ll b)//O(logn)
{
    if(!b) return a;
    return gcd(b,a%b);
}
ll modpow(ll x,ll n,ll m)//O(logn)// used for calculating (x^n)%m
{
    if(n==0) return 1%m;
    ll u = modpow(x,n/2,m);
    u = (u%m * u%m)%m;
    if(n%2==1)
        u = (u%m * x%m)%m;
    return u%m;
}
ll eulerstotientfunction(ll n)//O(sqrt(n))
{
    ll ans = n;
    for(ll i=2;i*i<=n;i++)
    {
        if(n%i==0)
        {
            while(n%i==0)
                n = n/i;
            ans -= ans/i;
        }
    }
    if(n>1)
        ans -= ans/n;
    return ans;
}
ll modinverse(ll x,ll m)//O(logn)
{
    ll temp = eulerstotientfunction(m);
    return modpow(x,temp-1,m);
}
ll ncr(ll n,ll k)
{
    ll res = 1;
    k = min(k,n-k);
    for(ll i=0;i<k;i++)
    {
        res *= (n-i);
        res /= (i+1);
    }
    return res;
}
int main()
{
    fastio();
    ll n,s;
    cin >> n >> s;
    std::vector<ll> arr(n),count;
    ll unique = 0;
    unordered_map<ll,ll> mp;
    for(ll i=0;i<n;i++)
    {
        cin >> arr[i];
        mp[arr[i]]++;
        if(mp[arr[i]]==1)
            unique++;
    }
    s = s*8;
    ll currsize = n*ceil(log2(unique));
    if(currsize<=s)
    {
        cout << 0 << endl;
        return 0;
    }
    s = s/n;
    s = (1LL<<s);
    for(auto it=mp.begin();it!=mp.end();it++)
        count.pb(it->second);
    sort(count.begin(), count.end());
    ll pref[unique];
    memset(pref,0,sizeof(pref));
    pref[0] = count[0];
    for(ll i=1;i<unique;i++)
    {
        pref[i] = count[i]+pref[i-1];
    }
    ll ans = pref[unique-1]-pref[s-1];
    for(ll i=1;i<unique && i+s-1<unique;i++)
    {
        ans = min(ans,pref[unique-1]-pref[i+s-1]+pref[i-1]);
    }
    cout << ans << endl;
}


/*      ###########################
        #  Author : Pranay Garg   #
        #  College : SGSITS       #
        ###########################
*/
#include<bits/stdc++.h>
#define ll long long int
#define ironman ios_base::sync_with_stdio(false);cin.tie(NULL);
#define MOD 1000000007
#define endl '\n'
#define INF 1e18L+1
#define mp make_pair
#define pb push_back
#define debug1(x) cout<<#x<<" "<<x<<endl;
#define debug2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<endl;
using namespace std;
template<class T> T max(T a, T b, T c) {
    return max(a, max(b, c));
}
template<class T> T min(T a, T b, T c) {
    return min(a, min(b, c));
}
void fastio()
{
    ironman
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
            freopen("error.txt","w",stderr);
    #endif
}
bool prime[100005];
void SieveOfEratosthenes(ll n)//O(nloglogn)
{
    memset(prime, true, sizeof(prime));

    for (ll p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
            for (ll i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }
}
bool isPrime(ll n)//O(sqrt(n))
{
    if(n<2)
        return false;
    for(ll i=2;i*i<=n;i++)
        if(n%i==0)
            return false;
    return true;
}
std::vector<ll> factors(ll n)//O(sqrt(n))
{
    std::vector<ll> f;
    for(ll i=2;i*i<=n;i++)
    {
        while(n%i==0)
        {
            f.push_back(i);
            n = n/i;
        }
    }
    if(n>1) f.push_back(n);
    return f;
}
ll gcd(ll a,ll b)//O(logn)
{
    if(!b) return a;
    return gcd(b,a%b);
}
ll modpow(ll x,ll n,ll m)//O(logn)// used for calculating (x^n)%m
{
    if(n==0) return 1%m;
    ll u = modpow(x,n/2,m);
    u = (u%m * u%m)%m;
    if(n%2==1)
        u = (u%m * x%m)%m;
    return u%m;
}
ll eulerstotientfunction(ll n)//O(sqrt(n))
{
    ll ans = n;
    for(ll i=2;i*i<=n;i++)
    {
        if(n%i==0)
        {
            while(n%i==0)
                n = n/i;
            ans -= ans/i;
        }
    }
    if(n>1)
        ans -= ans/n;
    return ans;
}
ll modinverse(ll x,ll m)//O(logn)
{
    ll temp = eulerstotientfunction(m);
    return modpow(x,temp-1,m);
}
ll ncr(ll n,ll k)
{
    ll res = 1;
    k = min(k,n-k);
    for(ll i=0;i<k;i++)
    {
        res *= (n-i);
        res /= (i+1);
    }
    return res;
}
int main()
{
    fastio();
    ll n,s;
    cin >> n >> s;
    std::vector<ll> arr(n),count;
    ll unique = 0;
    unordered_map<ll,ll> mp;
    for(ll i=0;i<n;i++)
    {
        cin >> arr[i];
        mp[arr[i]]++;
        if(mp[arr[i]]==1)
            unique++;
    }
    s = s*8;
    ll currsize = n*ceil(log2(unique));
    if(currsize<=s)
    {
        cout << 0 << endl;
        return 0;
    }
    s = s/n;
    s = (1LL<<s);
    for(auto it=mp.begin();it!=mp.end();it++)
        count.pb(it->second);
    sort(count.begin(), count.end());
    ll pref[unique+1];
    memset(pref,0,sizeof(pref));
    pref[0] = 0;
    for(ll i=1;i<=unique;i++)
    {
        pref[i] = count[i-1]+pref[i-1];
    }
    ll ans = INF;
//    cout << pref[unique] << "ffffff" << endl;
    for(ll i=0;i<=unique-s;i++)
    {
        ans = min(ans,pref[unique]-pref[i+s]+pref[i]);
    }
    cout << ans << endl;
}


/*      ###########################
        #  Author : Pranay Garg   #
        #  College : SGSITS       #
        ###########################
*/
#include<bits/stdc++.h>
#define ll long long int
#define ironman ios_base::sync_with_stdio(false);cin.tie(NULL);
#define MOD 1000000007
#define endl '\n'
#define INF 1e18L+1
#define mp make_pair
#define pb push_back
#define debug1(x) cout<<#x<<" "<<x<<endl;
#define debug2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<endl;
using namespace std;
template<class T> T max(T a, T b, T c) {
    return max(a, max(b, c));
}
template<class T> T min(T a, T b, T c) {
    return min(a, min(b, c));
}
void fastio()
{
    ironman
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
            freopen("error.txt","w",stderr);
    #endif
}
bool prime[100005];
void SieveOfEratosthenes(ll n)//O(nloglogn)
{
    memset(prime, true, sizeof(prime));

    for (ll p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
            for (ll i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }
}
bool isPrime(ll n)//O(sqrt(n))
{
    if(n<2)
        return false;
    for(ll i=2;i*i<=n;i++)
        if(n%i==0)
            return false;
    return true;
}
std::vector<ll> factors(ll n)//O(sqrt(n))
{
    std::vector<ll> f;
    for(ll i=2;i*i<=n;i++)
    {
        while(n%i==0)
        {
            f.push_back(i);
            n = n/i;
        }
    }
    if(n>1) f.push_back(n);
    return f;
}
ll gcd(ll a,ll b)//O(logn)
{
    if(!b) return a;
    return gcd(b,a%b);
}
ll modpow(ll x,ll n,ll m)//O(logn)// used for calculating (x^n)%m
{
    if(n==0) return 1%m;
    ll u = modpow(x,n/2,m);
    u = (u%m * u%m)%m;
    if(n%2==1)
        u = (u%m * x%m)%m;
    return u%m;
}
ll eulerstotientfunction(ll n)//O(sqrt(n))
{
    ll ans = n;
    for(ll i=2;i*i<=n;i++)
    {
        if(n%i==0)
        {
            while(n%i==0)
                n = n/i;
            ans -= ans/i;
        }
    }
    if(n>1)
        ans -= ans/n;
    return ans;
}
ll modinverse(ll x,ll m)//O(logn)
{
    ll temp = eulerstotientfunction(m);
    return modpow(x,temp-1,m);
}
ll ncr(ll n,ll k)
{
    ll res = 1;
    k = min(k,n-k);
    for(ll i=0;i<k;i++)
    {
        res *= (n-i);
        res /= (i+1);
    }
    return res;
}
int main()
{
    fastio();
    ll n,s;
    cin >> n >> s;
    std::vector<ll> arr(n),count;
    ll unique = 0;
    map<ll,ll> mp;
    for(ll i=0;i<n;i++)
    {
        cin >> arr[i];
        mp[arr[i]]++;
        if(mp[arr[i]]==1)
            unique++;
    }
    s = (s*8)/n;
    if(s>=unique)
    {
        cout << 0 << endl;
        return 0;
    }
    s = (1LL<<s);
    for(auto it:mp)
        count.pb(it.second);
    //sort(count.begin(), count.end());
    ll ans = INF,temp = 0;
    for(ll i=0;i<min(unique,s);i++)
        temp+=count[i];
    ans = min(ans,n-temp);
    for(ll i=min(unique,s);i<unique;i++)
    {
        temp+=count[i];
        temp-=count[i-s];
        ans = min(ans,n-temp);
    }
    cout << ans << endl;
}


/*      ###########################
        #  Author : Pranay Garg   #
        #  College : SGSITS       #
        ###########################
*/
#include<bits/stdc++.h>
#define ll long long int
#define ironman ios_base::sync_with_stdio(false);cin.tie(NULL);
#define MOD 1000000007
#define endl '\n'
#define INF 1e18L+1
#define mp make_pair
#define pb push_back
#define debug1(x) cout<<#x<<" "<<x<<endl;
#define debug2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<endl;
using namespace std;
template<class T> T max(T a, T b, T c) {
    return max(a, max(b, c));
}
template<class T> T min(T a, T b, T c) {
    return min(a, min(b, c));
}
void fastio()
{
    ironman
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
            freopen("error.txt","w",stderr);
    #endif
}
bool prime[100005];
void SieveOfEratosthenes(ll n)//O(nloglogn)
{
    memset(prime, true, sizeof(prime));

    for (ll p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
            for (ll i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }
}
bool isPrime(ll n)//O(sqrt(n))
{
    if(n<2)
        return false;
    for(ll i=2;i*i<=n;i++)
        if(n%i==0)
            return false;
    return true;
}
std::vector<ll> factors(ll n)//O(sqrt(n))
{
    std::vector<ll> f;
    for(ll i=2;i*i<=n;i++)
    {
        while(n%i==0)
        {
            f.push_back(i);
            n = n/i;
        }
    }
    if(n>1) f.push_back(n);
    return f;
}
ll gcd(ll a,ll b)//O(logn)
{
    if(!b) return a;
    return gcd(b,a%b);
}
ll modpow(ll x,ll n,ll m)//O(logn)// used for calculating (x^n)%m
{
    if(n==0) return 1%m;
    ll u = modpow(x,n/2,m);
    u = (u%m * u%m)%m;
    if(n%2==1)
        u = (u%m * x%m)%m;
    return u%m;
}
ll eulerstotientfunction(ll n)//O(sqrt(n))
{
    ll ans = n;
    for(ll i=2;i*i<=n;i++)
    {
        if(n%i==0)
        {
            while(n%i==0)
                n = n/i;
            ans -= ans/i;
        }
    }
    if(n>1)
        ans -= ans/n;
    return ans;
}
ll modinverse(ll x,ll m)//O(logn)
{
    ll temp = eulerstotientfunction(m);
    return modpow(x,temp-1,m);
}
ll ncr(ll n,ll k)
{
    ll res = 1;
    k = min(k,n-k);
    for(ll i=0;i<k;i++)
    {
        res *= (n-i);
        res /= (i+1);
    }
    return res;
}
int main()
{
    fastio();
    ll n,s;
    cin >> n >> s;
    std::vector<ll> arr(n),count;
    ll unique = 0;
    unordered_map<ll,ll> mp;
    for(ll i=0;i<n;i++)
    {
        cin >> arr[i];
        mp[arr[i]]++;
        if(mp[arr[i]]==1)
            unique++;
    }
    s = (s*8)/n;
    s = (1LL<<s);
    if(s>=unique)
    {
        cout << 0 << endl;
        return 0;
    }
    for(auto it:mp)
        count.pb(it.second);
    sort(count.begin(), count.end());
    ll ans = 0;
    for(ll i=0;i<min(unique,s);i++)
        ans+=count[i];
    ans = min(ans,n-ans);
    ll temp = ans;
    for(ll i=min(unique,s);i<unique;i++)
    {
        temp+=count[i]-count[i-s];
        ans = min(ans,n-temp);
    }
    cout << ans << endl;
}


/*      ###########################
        #  Author : Pranay Garg   #
        #  College : SGSITS       #
        ###########################
*/
#include<bits/stdc++.h>
#define ll long long int
#define ironman ios_base::sync_with_stdio(false);cin.tie(NULL);
#define MOD 1000000007
#define endl '\n'
#define INF 1e18L+1
#define mp make_pair
#define pb push_back
#define debug1(x) cout<<#x<<" "<<x<<endl;
#define debug2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<endl;
using namespace std;
template<class T> T max(T a, T b, T c) {
    return max(a, max(b, c));
}
template<class T> T min(T a, T b, T c) {
    return min(a, min(b, c));
}
void fastio()
{
    ironman
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
            freopen("error.txt","w",stderr);
    #endif
}
bool prime[100005];
void SieveOfEratosthenes(ll n)//O(nloglogn)
{
    memset(prime, true, sizeof(prime));

    for (ll p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
            for (ll i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }
}
bool isPrime(ll n)//O(sqrt(n))
{
    if(n<2)
        return false;
    for(ll i=2;i*i<=n;i++)
        if(n%i==0)
            return false;
    return true;
}
std::vector<ll> factors(ll n)//O(sqrt(n))
{
    std::vector<ll> f;
    for(ll i=2;i*i<=n;i++)
    {
        while(n%i==0)
        {
            f.push_back(i);
            n = n/i;
        }
    }
    if(n>1) f.push_back(n);
    return f;
}
ll gcd(ll a,ll b)//O(logn)
{
    if(!b) return a;
    return gcd(b,a%b);
}
ll modpow(ll x,ll n,ll m)//O(logn)// used for calculating (x^n)%m
{
    if(n==0) return 1%m;
    ll u = modpow(x,n/2,m);
    u = (u%m * u%m)%m;
    if(n%2==1)
        u = (u%m * x%m)%m;
    return u%m;
}
ll eulerstotientfunction(ll n)//O(sqrt(n))
{
    ll ans = n;
    for(ll i=2;i*i<=n;i++)
    {
        if(n%i==0)
        {
            while(n%i==0)
                n = n/i;
            ans -= ans/i;
        }
    }
    if(n>1)
        ans -= ans/n;
    return ans;
}
ll modinverse(ll x,ll m)//O(logn)
{
    ll temp = eulerstotientfunction(m);
    return modpow(x,temp-1,m);
}
ll ncr(ll n,ll k)
{
    ll res = 1;
    k = min(k,n-k);
    for(ll i=0;i<k;i++)
    {
        res *= (n-i);
        res /= (i+1);
    }
    return res;
}
int main()
{
    fastio();
    ll n,s;
    cin >> n >> s;
    std::vector<ll> arr(n),count;
    ll unique = 0;
    unordered_map<ll,ll> mp;
    for(ll i=0;i<n;i++)
    {
        cin >> arr[i];
        mp[arr[i]]++;
        if(mp[arr[i]]==1)
            unique++;
    }
    s = s*8;
    ll currsize = n*ceil(log2(unique));
    if(currsize<=s)
    {
        cout << 0 << endl;
        return 0;
    }
    s = s/n;
    s = (1LL<<s);
    for(auto it=mp.begin();it!=mp.end();it++)
        count.pb(it->second);
    sort(count.begin(), count.end());
    ll pref[unique];
    memset(pref,0,sizeof(pref));
    pref[0] = count[0];
    for(ll i=1;i<unique;i++)
    {
        pref[i] = count[i]+pref[i-1];
    }
    ll ans = pref[unique]-pref[max(s-1,0LL)];
    for(ll i=1;i<unique && i+s-1<unique;i++)
    {
        ans = min(ans,pref[unique-1]-pref[i+s-1]+pref[i-1]);
    }
    cout << ans << endl;
}


/*      ###########################
        #  Author : Pranay Garg   #
        #  College : SGSITS       #
        ###########################
*/
#include<bits/stdc++.h>
#define ll long long int
#define ironman ios_base::sync_with_stdio(false);cin.tie(NULL);
#define MOD 1000000007
#define endl '\n'
#define INF 1e18L+1
#define mp make_pair
#define pb push_back
#define debug1(x) cout<<#x<<" "<<x<<endl;
#define debug2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<endl;
using namespace std;
template<class T> T max(T a, T b, T c) {
    return max(a, max(b, c));
}
template<class T> T min(T a, T b, T c) {
    return min(a, min(b, c));
}
void fastio()
{
    ironman
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
            freopen("error.txt","w",stderr);
    #endif
}
bool prime[100005];
void SieveOfEratosthenes(ll n)//O(nloglogn)
{
    memset(prime, true, sizeof(prime));

    for (ll p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
            for (ll i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }
}
bool isPrime(ll n)//O(sqrt(n))
{
    if(n<2)
        return false;
    for(ll i=2;i*i<=n;i++)
        if(n%i==0)
            return false;
    return true;
}
std::vector<ll> factors(ll n)//O(sqrt(n))
{
    std::vector<ll> f;
    for(ll i=2;i*i<=n;i++)
    {
        while(n%i==0)
        {
            f.push_back(i);
            n = n/i;
        }
    }
    if(n>1) f.push_back(n);
    return f;
}
ll gcd(ll a,ll b)//O(logn)
{
    if(!b) return a;
    return gcd(b,a%b);
}
ll modpow(ll x,ll n,ll m)//O(logn)// used for calculating (x^n)%m
{
    if(n==0) return 1%m;
    ll u = modpow(x,n/2,m);
    u = (u%m * u%m)%m;
    if(n%2==1)
        u = (u%m * x%m)%m;
    return u%m;
}
ll eulerstotientfunction(ll n)//O(sqrt(n))
{
    ll ans = n;
    for(ll i=2;i*i<=n;i++)
    {
        if(n%i==0)
        {
            while(n%i==0)
                n = n/i;
            ans -= ans/i;
        }
    }
    if(n>1)
        ans -= ans/n;
    return ans;
}
ll modinverse(ll x,ll m)//O(logn)
{
    ll temp = eulerstotientfunction(m);
    return modpow(x,temp-1,m);
}
ll ncr(ll n,ll k)
{
    ll res = 1;
    k = min(k,n-k);
    for(ll i=0;i<k;i++)
    {
        res *= (n-i);
        res /= (i+1);
    }
    return res;
}
int main()
{
    fastio();
    ll n,s;
    cin >> n >> s;
    std::vector<ll> arr(n),count;
    ll unique = 0;
    unordered_map<ll,ll> mp;
    for(ll i=0;i<n;i++)
    {
        cin >> arr[i];
        mp[arr[i]]++;
        if(mp[arr[i]]==1)
            unique++;
    }
    s = s*8;
    ll currsize = n*ceil(log2(unique));
    if(currsize<=s)
    {
        cout << 0 << endl;
        return 0;
    }
    s = s/n;
    s = (1LL<<s);
    for(auto it=mp.begin();it!=mp.end();it++)
        count.pb(it->second);
    sort(count.begin(), count.end());
    ll pref[unique+1];
    memset(pref,0,sizeof(pref));
    pref[0] = 0;
    for(ll i=1;i<unique;i++)
    {
        pref[i] = count[i-1]+pref[i-1];
    }
    ll ans = INF;
    for(ll i=1;i+s-1<=unique;i++)
    {
        ans = min(ans,n-pref[i+s-1]+pref[i-1]);
    }
    cout << ans << endl;
}


/*      ###########################
        #  Author : Pranay Garg   #
        #  College : SGSITS       #
        ###########################
*/
#include<bits/stdc++.h>
#define ll long long int
#define ironman ios_base::sync_with_stdio(false);cin.tie(NULL);
#define MOD 1000000007
#define endl '\n'
#define INF 1e18L+1
#define mp make_pair
#define pb push_back
#define debug1(x) cout<<#x<<" "<<x<<endl;
#define debug2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<endl;
using namespace std;
template<class T> T max(T a, T b, T c) {
    return max(a, max(b, c));
}
template<class T> T min(T a, T b, T c) {
    return min(a, min(b, c));
}
void fastio()
{
    ironman
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
            freopen("error.txt","w",stderr);
    #endif
}
bool prime[100005];
void SieveOfEratosthenes(ll n)//O(nloglogn)
{
    memset(prime, true, sizeof(prime));

    for (ll p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
            for (ll i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }
}
bool isPrime(ll n)//O(sqrt(n))
{
    if(n<2)
        return false;
    for(ll i=2;i*i<=n;i++)
        if(n%i==0)
            return false;
    return true;
}
std::vector<ll> factors(ll n)//O(sqrt(n))
{
    std::vector<ll> f;
    for(ll i=2;i*i<=n;i++)
    {
        while(n%i==0)
        {
            f.push_back(i);
            n = n/i;
        }
    }
    if(n>1) f.push_back(n);
    return f;
}
ll gcd(ll a,ll b)//O(logn)
{
    if(!b) return a;
    return gcd(b,a%b);
}
ll modpow(ll x,ll n,ll m)//O(logn)// used for calculating (x^n)%m
{
    if(n==0) return 1%m;
    ll u = modpow(x,n/2,m);
    u = (u%m * u%m)%m;
    if(n%2==1)
        u = (u%m * x%m)%m;
    return u%m;
}
ll eulerstotientfunction(ll n)//O(sqrt(n))
{
    ll ans = n;
    for(ll i=2;i*i<=n;i++)
    {
        if(n%i==0)
        {
            while(n%i==0)
                n = n/i;
            ans -= ans/i;
        }
    }
    if(n>1)
        ans -= ans/n;
    return ans;
}
ll modinverse(ll x,ll m)//O(logn)
{
    ll temp = eulerstotientfunction(m);
    return modpow(x,temp-1,m);
}
ll ncr(ll n,ll k)
{
    ll res = 1;
    k = min(k,n-k);
    for(ll i=0;i<k;i++)
    {
        res *= (n-i);
        res /= (i+1);
    }
    return res;
}
int main()
{
    fastio();
    ll n,s;
    cin >> n >> s;
    std::vector<ll> arr(n);
    ll unique = 0;
    unordered_map<ll,ll> mp;
    for(ll i=0;i<n;i++)
    {
        cin >> arr[i];
        mp[arr[i]]++;
        if(mp[arr[i]]==1)
            unique++;
    }
    s = s*8;
    ll currsize = n*(ll)ceil(log2(unique));
    if(currsize<=s)
    {
        cout << 0 << endl;
        return 0;
    }
    s = s/n;
    s = (1LL<<s);
    s = unique-s;
    multiset<ll> sttt;
    for(auto it=mp.begin();it!=mp.end();it++)
    {
        sttt.insert(it->second);
    }
    ll ans = 0;
    for(auto it=sttt.begin();it!=sttt.end() && s>0;it++)
    {
        ans+=*it;
        s--;
    }
    cout << ans << endl;
}


/*      ###########################
        #  Author : Pranay Garg   #
        #  College : SGSITS       #
        ###########################
*/
#include<bits/stdc++.h>
#define ll long long int
#define ironman ios_base::sync_with_stdio(false);cin.tie(NULL);
#define MOD 1000000007
#define endl '\n'
#define INF 1e18L+1
#define mp make_pair
#define pb push_back
#define debug1(x) cout<<#x<<" "<<x<<endl;
#define debug2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<endl;
using namespace std;
template<class T> T max(T a, T b, T c) {
    return max(a, max(b, c));
}
template<class T> T min(T a, T b, T c) {
    return min(a, min(b, c));
}
void fastio()
{
    ironman
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
            freopen("error.txt","w",stderr);
    #endif
}
bool prime[100005];
void SieveOfEratosthenes(ll n)//O(nloglogn)
{
    memset(prime, true, sizeof(prime));

    for (ll p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
            for (ll i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }
}
bool isPrime(ll n)//O(sqrt(n))
{
    if(n<2)
        return false;
    for(ll i=2;i*i<=n;i++)
        if(n%i==0)
            return false;
    return true;
}
std::vector<ll> factors(ll n)//O(sqrt(n))
{
    std::vector<ll> f;
    for(ll i=2;i*i<=n;i++)
    {
        while(n%i==0)
        {
            f.push_back(i);
            n = n/i;
        }
    }
    if(n>1) f.push_back(n);
    return f;
}
ll gcd(ll a,ll b)//O(logn)
{
    if(!b) return a;
    return gcd(b,a%b);
}
ll modpow(ll x,ll n,ll m)//O(logn)// used for calculating (x^n)%m
{
    if(n==0) return 1%m;
    ll u = modpow(x,n/2,m);
    u = (u%m * u%m)%m;
    if(n%2==1)
        u = (u%m * x%m)%m;
    return u%m;
}
ll eulerstotientfunction(ll n)//O(sqrt(n))
{
    ll ans = n;
    for(ll i=2;i*i<=n;i++)
    {
        if(n%i==0)
        {
            while(n%i==0)
                n = n/i;
            ans -= ans/i;
        }
    }
    if(n>1)
        ans -= ans/n;
    return ans;
}
ll modinverse(ll x,ll m)//O(logn)
{
    ll temp = eulerstotientfunction(m);
    return modpow(x,temp-1,m);
}
ll ncr(ll n,ll k)
{
    ll res = 1;
    k = min(k,n-k);
    for(ll i=0;i<k;i++)
    {
        res *= (n-i);
        res /= (i+1);
    }
    return res;
}
int main()
{
    fastio();
    ll n,s;
    cin >> n >> s;
    std::vector<ll> arr(n),count;
    ll unique = 0;
    unordered_map<ll,ll> mp;
    for(ll i=0;i<n;i++)
    {
        cin >> arr[i];
        mp[arr[i]]++;
        if(mp[arr[i]]==1)
            unique++;
    }
    s = s*8;
    ll currsize = n*ceil(log2(unique));
    if(currsize<=s)
    {
        cout << 0 << endl;
        return 0;
    }
    s = s/n;
    s = (1LL<<s);
    for(auto it=mp.begin();it!=mp.end();it++)
        count.pb(it->second);
    sort(count.begin(), count.end());
    ll pref[unique];
    memset(pref,0,sizeof(pref));
    pref[0] = count[0];
    for(ll i=1;i<unique;i++)
    {
        pref[i] = count[i]+pref[i-1];
    }
    ll ans = pref[unique]-pref[s-1];
    for(ll i=1;i<unique && i+s-1<unique;i++)
    {
        ans = min(ans,pref[unique-1]-pref[i+s-1]+pref[i-1]);
    }
    cout << ans << endl;
}


#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define MOD(a) ((a)<0?((-1)*(a)):(a))

int cmp(const void *a, const void *b)
{
    return (*(long long *)a)-(*(long long *)b);
}

int cmp1(const void *a, const void *b)
{
    return (((int *)a)[0])-(((int *)b)[0]);
}

int main()
{
    long long n, I;
    scanf("%lld %lld",&n,&I);
    I*=8;
    long long a[n];
    for(int i=0; i<n; i++)
        scanf("%lld",&a[i]);
    qsort(a, n, sizeof(long long), cmp);
    long long cnt[n];
    long long d=0;
    for(long long i=0; i<n; i++) {
        long long element=a[i];
        cnt[d]=0;
        for( ; i<n && a[i]==element; i++)
            cnt[d]++;
        i--;
        d++;
    }
    double temp=((1.0)*I)/n;
    long long K=(long long) floor(pow(2.0, temp));
    while(ceil(log2(K*1.0))<=temp) K++;
    while(ceil(log2(K*1.0))>temp) K--;
    long long moves=0;
    long long i=0, j=d-1;
    while(d>K && i<=j) {
        if(cnt[i]<=cnt[j]) {
            moves+=cnt[i];
            i++;
        } else {
            moves+=cnt[j];
            j--;
        }
        d--;
    }
    printf("%lld\n",moves);
}


#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define MOD(a) ((a)<0?((-1)*(a)):(a))

int cmp(const void *a, const void *b)
{
    return (*(long long *)a)-(*(long long *)b);
}

int cmp1(const void *a, const void *b)
{
    return (((int *)a)[0])-(((int *)b)[0]);
}

int main()
{
    long long n, I;
    scanf("%lld %lld",&n,&I);
    I*=8;
    long long a[n];
    for(int i=0; i<n; i++)
        scanf("%lld",&a[i]);
    qsort(a, n, sizeof(long long), cmp);
    long long cnt[n];
    long long d=0;
    for(long long i=0; i<n; i++) {
        long long element=a[i];
        cnt[d]=0;
        for( ; i<n && a[i]==element; i++)
            cnt[d]++;
        i--;
        d++;
    }
    double temp=((1.0)*I)/n;
    long long K=(long long) floor(pow(2.0, temp));
    while(ceil(log2(K*1.0))<=temp) K++;
    while(ceil(log2(K*1.0))>temp) K--;
    long long moves=0;
    long long i=0, j=d-1;
    while(d>K && i<j) {
        if(cnt[i]<=cnt[j]) {
            moves+=cnt[i];
            i++;
        } else {
            moves+=cnt[j];
            j--;
        }
        d--;
    }

    printf("%lld\n",moves);
}


#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define MOD(a) ((a)<0?((-1)*(a)):(a))

int cmp(const void *a, const void *b)
{
    return (*(long long *)a)-(*(long long *)b);
}

int cmp1(const void *a, const void *b)
{
    return (((int *)a)[0])-(((int *)b)[0]);
}

int main()
{
    long long n, I;
    scanf("%lld %lld",&n,&I);
    I*=8;
    long long a[n];
    for(int i=0; i<n; i++)
        scanf("%lld",&a[i]);
    qsort(a, n, sizeof(long long), cmp);
    long long cnt[n];
    long long d=0;
    for(long long i=0; i<n; i++) {
        long long element=a[i];
        cnt[d]=0;
        for( ; i<n && a[i]==element; i++)
            cnt[d]++;
        i--;
        d++;
    }
    long long a1[d+1], a2[d+1]; a1[0]=0; a2[0]=0;
    for(long long i=1; i<=d; i++) a1[i]=a1[i-1]+cnt[i-1];
    for(long long i=1; i<=d; i++) a2[i]=a2[i-1]+cnt[i-1];

    double temp=((1.0)*I)/((1.0)*n);
    long long K=(long long) ceil(pow(2.0, temp));
    while(ceil(log2(K*1.0))<=temp) K++;
    while(ceil(log2(K*1.0))>temp) K--;

    if(d<=K) {
        printf("0\n");
        return 0;
    }

    long long i=0, j=d-1;
    long long reach=d-K;
    long long moves=n;
    for(long long i=0; i<=reach; i++) {
        moves=MIN(moves, a1[i] + a2[reach-i]);
    }

    printf("%lld\n",moves);
}


#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define MOD(a) ((a)<0?((-1)*(a)):(a))

int cmp(const void *a, const void *b)
{
    return (*(long long *)a)-(*(long long *)b);
}

int cmp1(const void *a, const void *b)
{
    return (((int *)a)[0])-(((int *)b)[0]);
}

int main()
{
    long long n, I;
    scanf("%lld %lld",&n,&I);
    I*=8;
    long long a[n];
    for(int i=0; i<n; i++)
        scanf("%lld",&a[i]);

    if((I/n)>20) {
        printf("0\n");
        return 0;
    }

    qsort(a, n, sizeof(long long), cmp);
    long long cnt[n];
    long long d=0;
    for(long long i=0; i<n; i++) {
        long long element=a[i];
        cnt[d]=0;
        for( ; i<n && a[i]==element; i++)
            cnt[d]++;
        i--;
        d++;
    }

    long long k=I/n;
    long long K= 1<<k;

    if(d<=K) {
        printf("0\n");
        return 0;
    }

    long long a1[d+1], a2[d+1]; a1[0]=0; a2[0]=0;
    for(long long i=1; i<=d; i++) a1[i]=a1[i-1]+cnt[i-1];
    for(long long i=1; i<=d; i++) a2[i]=a2[i-1]+cnt[d-i];

    long long i=0, j=d-1;
    long long reach=d-K;
    long long moves=2147483647;
    for(long long i=0; i<=reach; i++) {
        moves=MIN(moves, a1[i] + a2[reach-i]);
    }

    printf("%lld\n",moves);
}


#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define MOD(a) ((a)<0?((-1)*(a)):(a))

int cmp(const void *a, const void *b)
{
    return (*(long long *)a)-(*(long long *)b);
}

int cmp1(const void *a, const void *b)
{
    return (((int *)a)[0])-(((int *)b)[0]);
}

int main()
{
    long long n, I;
    scanf("%lld %lld",&n,&I);
    I*=8;
    long long a[n];
    for(int i=0; i<n; i++)
        scanf("%lld",&a[i]);

    if((I/n)>20) {
        printf("0\n");
        return 0;
    }

    qsort(a, n, sizeof(long long), cmp);
    long long cnt[n];
    long long d=0;
    for(long long i=0; i<n; i++) {
        long long element=a[i];
        cnt[d]=0;
        for( ; i<n && a[i]==element; i++)
            cnt[d]++;
        i--;
        d++;
    }

    long long k=I/n;
    long long K= 1<<k;

    if(d<=K) {
        printf("0\n");
        return 0;
    }

    long long a1[d+1], a2[d+1]; a1[0]=0; a2[0]=0;
    for(long long i=1; i<=d; i++) a2[i]=a2[i-1]+cnt[d-i];
    for(long long i=1; i<=d; i++) a1[i]=a1[i-1]+cnt[i-1];

    long long i=0, j=d-1;
    long long reach=d-K;
    long long moves=2147483647;
    for(long long i=0; i<=reach; i++) {
        moves=MIN(moves, a1[i] + a2[reach-i]);
    }

    printf("%lld\n",moves);
}


#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define MOD(a) ((a)<0?((-1)*(a)):(a))

int cmp(const void *a, const void *b)
{
    return (*(long long *)a)-(*(long long *)b);
}

int cmp1(const void *a, const void *b)
{
    return (((int *)a)[0])-(((int *)b)[0]);
}

int main()
{
    long long n, I;
    scanf("%lld %lld",&n,&I);
    I*=8;
    long long a[n];
    for(int i=0; i<n; i++)
        scanf("%lld",&a[i]);

    /*if((I/n)>20) {
        printf("0\n");
        return 0;
    }*/

    qsort(a, n, sizeof(long long), cmp);
    long long cnt[n];
    long long d=0;
    for(long long i=0; i<n; i++) {
        long long element=a[i];
        cnt[d]=0;
        for( ; i<n && a[i]==element; i++)
            cnt[d]++;
        i--;
        d++;
    }

    long long k=I/n;
    long long K= 1<<k;

    if(d<=K) {
        printf("0\n");
        return 0;
    }

    long long a1[d+1], a2[d+1]; a1[0]=0; a2[0]=0;
    for(long long i=1; i<=d; i++) a1[i]=a1[i-1]+cnt[i-1];
    for(long long i=1; i<=d; i++) a2[i]=a2[i-1]+cnt[d-i];

    long long i=0, j=d-1;
    long long reach=d-K;
    long long moves=2147483647;
    for(long long i=0; i<=reach; i++) {
        moves=MIN(moves, a1[i] + a2[reach-i]);
    }

    printf("%lld\n",moves);
}


#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define MOD(a) ((a)<0?((-1)*(a)):(a))

int cmp(const void *a, const void *b)
{
    return (*(long long *)a)-(*(long long *)b);
}

int cmp1(const void *a, const void *b)
{
    return (((int *)a)[0])-(((int *)b)[0]);
}

int main()
{
    long long n, I;
    scanf("%lld %lld",&n,&I);
    I*=8;
    long long a[n];
    for(int i=0; i<n; i++)
        scanf("%lld",&a[i]);
    qsort(a, n, sizeof(long long), cmp);
    long long cnt[n];
    long long d=0;
    for(long long i=0; i<n; i++) {
        long long element=a[i];
        cnt[d]=0;
        for( ; i<n && a[i]==element; i++)
            cnt[d]++;
        i--;
        d++;
    }
    long long a1[d+1], a2[d+1]; a1[0]=0; a2[0]=0;
    for(long long i=1; i<=d; i++) a1[i]=a1[i-1]+cnt[i-1];
    for(long long i=1; i<=d; i++) a2[i]=a2[i-1]+cnt[d-i];

    double temp=((1.0)*I)/((1.0)*n);
    long long K=(long long) ceil(pow(2.0, temp));
    while(ceil(log2(K*1.0))<=temp) K++;
    while(ceil(log2(K*1.0))>temp) K--;

    if(d<=K) {
        printf("0\n");
        return 0;
    }

    long long i=0, j=d-1;
    long long reach=d-K;
    long long moves=n;
    for(long long i=0; i<=reach; i++) {
        moves=MIN(moves, a1[i] + a2[reach-i]);
    }

    printf("%lld\n",moves);
}


#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define MOD(a) ((a)<0?((-1)*(a)):(a))

int cmp(const void *a, const void *b)
{
    return (*(long long *)a)-(*(long long *)b);
}

int cmp1(const void *a, const void *b)
{
    return (((int *)a)[0])-(((int *)b)[0]);
}

int main()
{
    long long n, I;
    scanf("%lld %lld",&n,&I);
    I*=8;
    long long a[n];
    for(int i=0; i<n; i++)
        scanf("%lld",&a[i]);
    qsort(a, n, sizeof(long long), cmp);
    long long cnt[n];
    long long d=0;
    for(long long i=0; i<n; i++) {
        long long element=a[i];
        cnt[d]=0;
        for( ; i<n && a[i]==element; i++)
            cnt[d]++;
        i--;
        d++;
    }
    double temp=((1.0)*I)/n;
    long long K=(long long) floor(pow(2.0, temp));
    while(ceil(log2(K*1.0))<=temp) K++;
    K--;
    long long moves=0;
    long long i=0, j=d-1;
    while(d>K && i<=j) {
        if(cnt[i]<=cnt[j]) {
            moves+=cnt[i];
            i++;
        } else {
            moves+=cnt[j];
            j--;
        }
        d--;
    }
    printf("%lld\n",moves);
}


#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define MOD(a) ((a)<0?((-1)*(a)):(a))

int cmp(const void *a, const void *b)
{
    return (*(long long *)a)-(*(long long *)b);
}

int cmp1(const void *a, const void *b)
{
    return (((int *)a)[0])-(((int *)b)[0]);
}

int main()
{
    long long n, I;
    scanf("%lld %lld",&n,&I);
    I*=8;
    long long a[n];
    for(int i=0; i<n; i++)
        scanf("%lld",&a[i]);
    qsort(a, n, sizeof(long long), cmp);
    long long cnt[n];
    long long d=0;
    for(long long i=0; i<n; i++) {
        long long element=a[i];
        cnt[d]=0;
        for( ; i<n && a[i]==element; i++)
            cnt[d]++;
        i--;
        d++;
    }
    long long a1[d+1], a2[d+1]; a1[0]=0; a2[0]=0;
    for(long long i=1; i<=d; i++) a1[i]=a1[i-1]+cnt[i-1];
    for(long long i=1; i<=d; i++) a2[i]=a2[i-1]+cnt[d-i];

    double temp=((1.0)*I)/((1.0)*n);
    long long K=(long long) ceil(pow(2.0, temp));
    while(ceil(log2(K*1.0))<=temp) K++;
    while(ceil(log2(K*1.0))>temp) K--;

    if((I/n)>20) {
        printf("0\n");
        return 0;
    }
    if(d<=K) {
        printf("0\n");
        return 0;
    }

    long long i=0, j=d-1;
    long long reach=d-K;
    long long moves=2147483647;
    for(long long i=0; i<=reach; i++) {
        moves=MIN(moves, a1[i] + a2[reach-i]);
    }

    printf("%lld\n",moves);
}


#include <algorithm>
#include <iostream>
#include <vector>
#include <cmath>
#include <map>
#include <set>

long long bin_pow (long long a , long long n) {
  if(n == 0){
    return 1;
  }
  if(n % 2 == 1){
    long long cnt = a * bin_pow(a , n - 1);
    return cnt;
  }
  else {
    long long cnt = bin_pow(a , n / 2);
    return cnt * cnt;
  }
}
int main() {

  long long n, I;
  std::cin >> n >> I;

  I *= 8;

  std::map<long long, int> mp;
  std::vector<long long> a(n);
  for(int i = 0; i < n; ++i) {
    std::cin >> a[i];
    mp[a[i]]++;

  }

  long long k = I / n;
 // std::cout << k << std::endl;
  long long K = bin_pow(2, k);
  if(I % n == 0) {
    K--;
  }
  //if(k == 0) K = 1;
  //std::cout << "K " <<  K << std::endl;

  int need = 9999999, del = 0;

  std::vector<int> s;
  //std::cout << "MP: ";
  for(auto& it : mp) {
    s.push_back(it.second);
    //std::cout << it.second << ' ';
  }
  //std::cout << std::endl;

  std::sort(begin(s), end(s));

  for(long long C = std::max(0ll, K - 3); C <= K; ++C) {
    long long curr_k = log2(C);
    if(curr_k != k) continue;

    //std::cout << C << ' ' << curr_k << std::endl;
    int curr_del = 0, curr_need = 0;
    for(auto& it : s) {
      if((s.size() - curr_del) <= C) break;
      curr_del++;
      // std::cout << it << std::endl;
      curr_need += it;
    }
    //std::cout << curr_need << std::endl;
    need = std::min(need, curr_need);

  }

  if(need == 9999999) {
    int curr_del = 0, curr_need = 0;
    for(auto& it : s) {
      if((s.size() - curr_del) <= K) break;
      curr_del++;
      // std::cout << it << std::endl;
      curr_need += it;
    }
    std::cout << curr_need << std::endl;
  } else {
    std::cout << need << std::endl;
  }

  return 0;
}


#include <algorithm>
#include <iostream>
#include <numeric>
#include <vector>
#include <cmath>
#include <map>

long long bin_pow (long long a , long long n) {
  if(n == 0){
    return 1;
  }
  if(n % 2 == 1){
    long long cnt = a * bin_pow(a , n - 1);
    return cnt;
  }
  else {
    long long cnt = bin_pow(a , n / 2);
    return cnt * cnt;
  }
}

signed main() {

  std::size_t n;
  std::cin >> n;

  long long I;
  std::cin >> I;

  std::map<int, int> mp;
  for(std::size_t i = 0; i < n; ++i) {
    int x; std::cin >> x;
    mp[x]++;
  }

  std::vector<int> pref, suf;
  for(const auto& pair : mp) {
    suf.push_back(pair.second);
    pref.push_back(pair.second);
  }

  std::reverse(begin(suf), end(suf));

  for(std::size_t i = 1; i < pref.size(); ++i) {
    suf[i] = suf[i] + suf[i - 1];
    pref[i] = pref[i] + pref[i - 1];
  }

  std::reverse(begin(suf), end(suf));

  I = I * 8;

  long long k = I / n;

  long long K = bin_pow(2, std::min(k, 20ll));

  if(K >= pref.size()) {
    std::cout << 0 << std::endl;
  } else {

    int len = pref.size();
    int ans = std::numeric_limits<int>::max();
    for(int i = 0; i < pref.size() - K; ++i) {
      //std::cout << i << ' ' << K + i << ' ' << pref[i] << ' ' << suf[K + i + 1] << std::endl;
      ans = std::min(ans, pref[i] + suf[K + i + 1]);
    }
    ans = std::min(ans, pref[len - K - 1]);
    std::reverse(begin(suf), end(suf));
    ans = std::min(ans, suf[len - K - 1]);

    std::cout << ans << std::endl;

  }

  return 0;
}


#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <set>

long long bin_pow (long long a , long long n) {
  if(n == 0){
    return 1;
  }
  if(n % 2 == 1){
    long long cnt = a * bin_pow(a , n - 1);
    return cnt;
  }
  else {
    long long cnt = bin_pow(a , n / 2);
    return cnt * cnt;
  }
}
int main() {

  long long n, I;
  std::cin >> n >> I;

  I *= 8;

  std::map<long long, int> mp;
  std::vector<long long> a(n);
  for(int i = 0; i < n; ++i) {
    std::cin >> a[i];
    mp[a[i]]++;

  }

  long long k = I / n;
  if(I % n == 0) k++;
 // std::cout << k << std::endl;
  long long K = bin_pow(2, k);
  if(k == 0) K = 1;
  //std::cout << "K " <<  K << std::endl;

  int need = 0, del = 0;

  std::vector<int> s;
  //std::cout << "MP: ";
  for(auto& it : mp) {
    s.push_back(it.second);
    //std::cout << it.second << ' ';
  }
  //std::cout << std::endl;

  std::sort(begin(s), end(s));

  for(auto& it : s) {
    if((s.size() - del) <= K) break;
    del++;
   // std::cout << it << std::endl;
    need += it;
  }

  std::cout << need << std::endl;

  return 0;
}


#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <set>

long long bin_pow (long long a , long long n) {
  if(n == 0){
    return 1;
  }
  if(n % 2 == 1){
    long long cnt = a * bin_pow(a , n - 1);
    return cnt;
  }
  else {
    long long cnt = bin_pow(a , n / 2);
    return cnt * cnt;
  }
}
int main() {

  long long n, I;
  std::cin >> n >> I;

  I *= 8;

  std::map<long long, int> mp;
  std::vector<long long> a(n);
  for(int i = 0; i < n; ++i) {
    std::cin >> a[i];
    mp[a[i]]++;

  }

  long long k = I / n;
 // std::cout << k << std::endl;
  long long K = bin_pow(k, 2) + 1;
  if(k == 0) K = 1;
  //std::cout << "K " <<  K << std::endl;

  int need = 0, del = 0;

  std::vector<int> s;
  //std::cout << "MP: ";
  for(auto& it : mp) {
    s.push_back(it.second);
    //std::cout << it.second << ' ';
  }
  //std::cout << std::endl;

  std::sort(begin(s), end(s));

  for(auto& it : s) {
    if((s.size() - del) <= K) break;
    del++;
   // std::cout << it << std::endl;
    need += it;
  }

  std::cout << need << std::endl;

  return 0;
}


#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <set>

long long bin_pow (long long a , long long n) {
  if(n == 0){
    return 1;
  }
  if(n % 2 == 1){
    long long cnt = a * bin_pow(a , n - 1);
    return cnt;
  }
  else {
    long long cnt = bin_pow(a , n / 2);
    return cnt * cnt;
  }
}
int main() {

  long long n, I;
  std::cin >> n >> I;

  I *= 8;

  std::map<long long, int> mp;
  std::vector<long long> a(n);
  for(int i = 0; i < n; ++i) {
    std::cin >> a[i];
    mp[a[i]]++;

  }

  long long k = I / n;
 // std::cout << k << std::endl;
  long long K = bin_pow(2, k);
  //if(k == 0) K = 1;
  //std::cout << "K " <<  K << std::endl;

  int need = 0, del = 0;

  std::vector<int> s;
  //std::cout << "MP: ";
  for(auto& it : mp) {
    s.push_back(it.second);
    //std::cout << it.second << ' ';
  }
  //std::cout << std::endl;

  std::sort(begin(s), end(s));

  for(auto& it : s) {
    if((s.size() - del) <= K) break;
    del++;
   // std::cout << it << std::endl;
    need += it;
  }

  std::cout << need << std::endl;

  return 0;
}


#include <algorithm>
#include <iostream>
#include <vector>
#include <cmath>
#include <map>
#include <set>

long long bin_pow (long long a , long long n) {
  if(n == 0){
    return 1;
  }
  if(n % 2 == 1){
    long long cnt = a * bin_pow(a , n - 1);
    return cnt;
  }
  else {
    long long cnt = bin_pow(a , n / 2);
    return cnt * cnt;
  }
}
int main() {

  long long n, I;
  std::cin >> n >> I;

  I *= 8;

  std::map<long long, int> mp;
  std::vector<long long> a(n);
  for(int i = 0; i < n; ++i) {
    std::cin >> a[i];
    mp[a[i]]++;

  }

  long long k = I / n;
 // std::cout << k << std::endl;
  long long K = bin_pow(2, k);
  if(I % n == 0) {
    K--;
  }
  //if(k == 0) K = 1;
  //std::cout << "K " <<  K << std::endl;

  int need = 9999999, del = 0;

  std::vector<int> s;
  //std::cout << "MP: ";
  for(auto& it : mp) {
    s.push_back(it.second);
    //std::cout << it.second << ' ';
  }
  //std::cout << std::endl;

  std::sort(begin(s), end(s));

  for(long long C = std::max(0ll, K - 1); C <= K; ++C) {
    long long curr_k = log2(C);
    if(curr_k != k) continue;

    //std::cout << C << ' ' << curr_k << std::endl;
    int curr_del = 0, curr_need = 0;
    for(auto& it : s) {
      if((s.size() - curr_del) <= C) break;
      curr_del++;
      // std::cout << it << std::endl;
      curr_need += it;
    }
    //std::cout << curr_need << std::endl;
    need = std::min(need, curr_need);

  }

  std::cout << need << std::endl;

  return 0;
}


#include <algorithm>
#include <iostream>
#include <vector>
#include <cmath>
#include <map>
#include <set>

long long bin_pow (long long a , long long n) {
  if(n == 0){
    return 1;
  }
  if(n % 2 == 1){
    long long cnt = a * bin_pow(a , n - 1);
    return cnt;
  }
  else {
    long long cnt = bin_pow(a , n / 2);
    return cnt * cnt;
  }
}
int main() {

  long long n, I;
  std::cin >> n >> I;

  I *= 8;

  std::map<long long, int> mp;
  std::vector<long long> a(n);
  for(int i = 0; i < n; ++i) {
    std::cin >> a[i];
    mp[a[i]]++;

  }

  long long k = I / n;
 // std::cout << k << std::endl;
  long long K = bin_pow(2, k);
  if(I % n == 0) {
    K--;
  }
  //if(k == 0) K = 1;
  //std::cout << "K " <<  K << std::endl;

  int need = 9999999, del = 0;

  std::vector<int> s;
  //std::cout << "MP: ";
  for(auto& it : mp) {
    s.push_back(it.second);
    //std::cout << it.second << ' ';
  }
  //std::cout << std::endl;

  std::sort(begin(s), end(s));

  for(long long C = std::max(0ll, K - 3); C <= K; ++C) {
    long long curr_k = log2(C);
    if(curr_k != k) continue;

    //std::cout << C << ' ' << curr_k << std::endl;
    int curr_del = 0, curr_need = 0;
    for(auto& it : s) {
      if((s.size() - curr_del) <= C) break;
      curr_del++;
      // std::cout << it << std::endl;
      curr_need += it;
    }
    //std::cout << curr_need << std::endl;
    need = std::min(need, curr_need);

  }

  std::cout << need << std::endl;

  if(need == 9999999) {
    int curr_del = 0, curr_need = 0;
    for(auto& it : s) {
      if((s.size() - curr_del) <= K) break;
      curr_del++;
      // std::cout << it << std::endl;
      curr_need += it;
    }
    std::cout << curr_need << std::endl;
  }

  return 0;
}


#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <set>

long long bin_pow (long long a , long long n) {
  if(n == 0){
    return 1;
  }
  if(n % 2 == 1){
    long long cnt = a * bin_pow(a , n - 1);
    return cnt;
  }
  else {
    long long cnt = bin_pow(a , n / 2);
    return cnt * cnt;
  }
}
int main() {

  long long n, I;
  std::cin >> n >> I;

  I *= 8;

  std::map<long long, int> mp;
  std::vector<long long> a(n);
  for(int i = 0; i < n; ++i) {
    std::cin >> a[i];
    mp[a[i]]++;

  }

  long long k = I / n;
 // std::cout << k << std::endl;
  long long K = bin_pow(2, k);
  if(I % n == 0) {
    K++;
  }
  //if(k == 0) K = 1;
  //std::cout << "K " <<  K << std::endl;

  int need = 0, del = 0;

  std::vector<int> s;
  //std::cout << "MP: ";
  for(auto& it : mp) {
    s.push_back(it.second);
    //std::cout << it.second << ' ';
  }
  //std::cout << std::endl;

  std::sort(begin(s), end(s));

  for(auto& it : s) {
    if((s.size() - del) <= K) break;
    del++;
   // std::cout << it << std::endl;
    need += it;
  }

  std::cout << need << std::endl;

  return 0;
}


#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <set>

long long bin_pow (long long a , long long n) {
  if(n == 0){
    return 1;
  }
  if(n % 2 == 1){
    long long cnt = a * bin_pow(a , n - 1);
    return cnt;
  }
  else {
    long long cnt = bin_pow(a , n / 2);
    return cnt * cnt;
  }
}
int main() {

  long long n, I;
  std::cin >> n >> I;

  I *= 8;

  std::map<int, int> mp;
  std::vector<int> a(n);
  for(int i = 0; i < n; ++i) {
    std::cin >> a[i];
    mp[a[i]]++;

  }

  long long k = I / n;
 // std::cout << k << std::endl;
  long long K = bin_pow(k - 1, 2) + k + 1;
  if(k == 0) K = 1;
  //std::cout << "K " <<  K << std::endl;

  int need = 0, del = 0;

  std::vector<int> s;
  //std::cout << "MP: ";
  for(auto& it : mp) {
    s.push_back(it.second);
    //std::cout << it.second << ' ';
  }
  //std::cout << std::endl;

  std::sort(begin(s), end(s));

  for(auto& it : s) {
    if((s.size() - del) <= K) break;
    del++;
   // std::cout << it << std::endl;
    need += it;
  }

  std::cout << need << std::endl;

  return 0;
}


#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <set>

long long bin_pow (long long a , long long n) {
  if(n == 0){
    return 1;
  }
  if(n % 2 == 1){
    long long cnt = a * bin_pow(a , n - 1);
    return cnt;
  }
  else {
    long long cnt = bin_pow(a , n / 2);
    return cnt * cnt;
  }
}
int main() {

  long long n, I;
  std::cin >> n >> I;

  I *= 8;

  std::map<long long, int> mp;
  std::vector<long long> a(n);
  for(int i = 0; i < n; ++i) {
    std::cin >> a[i];
    mp[a[i]]++;

  }

  long long k = I / n;
 // std::cout << k << std::endl;
  long long K = bin_pow(2, k);
  if(I % n == 0) {
    K--;
  }
  //if(k == 0) K = 1;
  //std::cout << "K " <<  K << std::endl;

  int need = 0, del = 0;

  std::vector<int> s;
  //std::cout << "MP: ";
  for(auto& it : mp) {
    s.push_back(it.second);
    //std::cout << it.second << ' ';
  }
  //std::cout << std::endl;

  std::sort(begin(s), end(s));

  for(auto& it : s) {
    if((s.size() - del) <= K) break;
    del++;
   // std::cout << it << std::endl;
    need += it;
  }

  std::cout << need << std::endl;

  return 0;
}


#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <set>

long long bin_pow (long long a , long long n) {
  if(n == 0){
    return 1;
  }
  if(n % 2 == 1){
    long long cnt = a * bin_pow(a , n - 1);
    return cnt;
  }
  else {
    long long cnt = bin_pow(a , n / 2);
    return cnt * cnt;
  }
}
int main() {

  long long n, I;
  std::cin >> n >> I;

  I *= 8;

  std::map<long long, int> mp;
  std::vector<long long> a(n);
  for(int i = 0; i < n; ++i) {
    std::cin >> a[i];
    mp[a[i]]++;

  }

  long long k = I / n;
 // std::cout << k << std::endl;
  long long K = bin_pow(k - 1, 2) + k + 1;
  if(k == 0) K = 1;
  //std::cout << "K " <<  K << std::endl;

  int need = 0, del = 0;

  std::vector<int> s;
  //std::cout << "MP: ";
  for(auto& it : mp) {
    s.push_back(it.second);
    //std::cout << it.second << ' ';
  }
  //std::cout << std::endl;

  std::sort(begin(s), end(s));

  for(auto& it : s) {
    if((s.size() - del) <= K) break;
    del++;
   // std::cout << it << std::endl;
    need += it;
  }

  std::cout << need << std::endl;

  return 0;
}


#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <set>

long long bin_pow (long long a , long long n) {
  if(n == 0){
    return 1;
  }
  if(n % 2 == 1){
    long long cnt = a * bin_pow(a , n - 1);
    return cnt;
  }
  else {
    long long cnt = bin_pow(a , n / 2);
    return cnt * cnt;
  }
}
int main() {

  long long n, I;
  std::cin >> n >> I;

  I *= 8;

  std::map<int, int> mp;
  std::vector<int> a(n);
  for(int i = 0; i < n; ++i) {
    std::cin >> a[i];
    mp[a[i]]++;

  }

  long long k = I / n;
 // std::cout << k << std::endl;
  long long K = bin_pow(k - 1, 2) + k + 1;
  //std::cout << "K " <<  K << std::endl;

  int need = 0, del = 0;

  std::vector<int> s;
  //std::cout << "MP: ";
  for(auto& it : mp) {
    s.push_back(it.second);
    //std::cout << it.second << ' ';
  }
  //std::cout << std::endl;

  std::sort(begin(s), end(s));

  for(auto& it : s) {
    if((s.size() - del) <= K) break;
    del++;
   // std::cout << it << std::endl;
    need += it;
  }

  std::cout << need << std::endl;

  return 0;
}


#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <set>

long long bin_pow (long long a , long long n) {
  if(n == 0){
    return 1;
  }
  if(n % 2 == 1){
    long long cnt = a * bin_pow(a , n - 1);
    return cnt;
  }
  else {
    long long cnt = bin_pow(a , n / 2);
    return cnt * cnt;
  }
}
int main() {

  long long n, I;
  std::cin >> n >> I;

  I *= 8;

  std::map<long long, int> mp;
  std::vector<long long> a(n);
  for(int i = 0; i < n; ++i) {
    std::cin >> a[i];
    mp[a[i]]++;

  }

  long long k = I / n;
  if(I % n == 0) k++;
 // std::cout << k << std::endl;
  long long K = bin_pow(k, 2) + 1;
  if(k == 0) K = 1;
  //std::cout << "K " <<  K << std::endl;

  int need = 0, del = 0;

  std::vector<int> s;
  //std::cout << "MP: ";
  for(auto& it : mp) {
    s.push_back(it.second);
    //std::cout << it.second << ' ';
  }
  //std::cout << std::endl;

  std::sort(begin(s), end(s));

  for(auto& it : s) {
    if((s.size() - del) <= K) break;
    del++;
   // std::cout << it << std::endl;
    need += it;
  }

  std::cout << need << std::endl;

  return 0;
}


#include <algorithm>
#include <iostream>
#include <vector>
#include <map>

long long bin_pow (long long a , long long n) {
  if(n == 0){
    return 1;
  }
  if(n % 2 == 1){
    long long cnt = a * bin_pow(a , n - 1);
    return cnt;
  }
  else {
    long long cnt = bin_pow(a , n / 2);
    return cnt * cnt;
  }
}

signed main() {

  std::size_t n;
  std::cin >> n;

  long long I;
  std::cin >> I;

  std::map<int, int> mp;
  for(std::size_t i = 0; i < n; ++i) {
    int x; std::cin >> x;
    mp[x]++;
  }

  std::vector<int> pref;
  for(const auto& pair : mp) {
    pref.push_back(pair.second);
  }

  std::sort(begin(pref), end(pref));

  for(std::size_t i = 1; i < pref.size(); ++i) {
    pref[i] = pref[i] + pref[i - 1];
  }

  I = I * 8;

  long long k = I / n;

  long long K = bin_pow(2, k);

  if(K >= pref.size()) {
    std::cout << 0 << std::endl;
  } else {
    std::cout << pref[pref.size() - K - 1] << std::endl;
   }

  return 0;
}


#include <algorithm>
#include <iostream>
#include <vector>
#include <cmath>
#include <map>

long long bin_pow (long long a , long long n) {
  if(n == 0){
    return 1;
  }
  if(n % 2 == 1){
    long long cnt = a * bin_pow(a , n - 1);
    return cnt;
  }
  else {
    long long cnt = bin_pow(a , n / 2);
    return cnt * cnt;
  }
}

signed main() {

  std::size_t n;
  std::cin >> n;

  long long I;
  std::cin >> I;

  std::map<int, int> mp;
  for(std::size_t i = 0; i < n; ++i) {
    int x; std::cin >> x;
    mp[x]++;
  }

  std::vector<int> pref;
  for(const auto& pair : mp) {
    pref.push_back(pair.second);
  }

  std::sort(begin(pref), end(pref));

  for(std::size_t i = 1; i < pref.size(); ++i) {
    pref[i] = pref[i] + pref[i - 1];
  }

  I = I * 8;

  long long k = ceil(I / n);

  if(I % n == 0) k++;

  long long K = bin_pow(2, k);

  if(K >= pref.size()) {
    std::cout << 0 << std::endl;
  } else {
    std::cout << pref[pref.size() - K - 1] << std::endl;
   }

  return 0;
}


#include <algorithm>
#include <iostream>
#include <vector>
#include <cmath>
#include <map>

long long bin_pow (long long a , long long n) {
  if(n == 0){
    return 1;
  }
  if(n % 2 == 1){
    long long cnt = a * bin_pow(a , n - 1);
    return cnt;
  }
  else {
    long long cnt = bin_pow(a , n / 2);
    return cnt * cnt;
  }
}

signed main() {

  std::size_t n;
  std::cin >> n;

  long long I;
  std::cin >> I;

  std::map<int, int> mp;
  for(std::size_t i = 0; i < n; ++i) {
    int x; std::cin >> x;
    mp[x]++;
  }

  std::vector<int> pref;
  for(const auto& pair : mp) {
    pref.push_back(pair.second);
  }

  std::sort(begin(pref), end(pref));

  for(std::size_t i = 1; i < pref.size(); ++i) {
    pref[i] = pref[i] + pref[i - 1];
  }

  I = I * 8;

  long long k = ceil(I / n);

  long long K = bin_pow(2, k);

  if(I % n == 0) K--;

  if(K >= pref.size()) {
    std::cout << 0 << std::endl;
  } else {
    std::cout << pref[pref.size() - K - 1] << std::endl;
   }

  return 0;
}


#include <algorithm>
#include <iostream>
#include <vector>
#include <cmath>
#include <map>
#include <set>

long long bin_pow (long long a , long long n) {
  if(n == 0){
    return 1;
  }
  if(n % 2 == 1){
    long long cnt = a * bin_pow(a , n - 1);
    return cnt;
  }
  else {
    long long cnt = bin_pow(a , n / 2);
    return cnt * cnt;
  }
}
int main() {

  long long n, I;
  std::cin >> n >> I;

  I *= 8;

  std::map<long long, int> mp;
  std::vector<long long> a(n);
  for(int i = 0; i < n; ++i) {
    std::cin >> a[i];
    mp[a[i]]++;

  }

  long long k = I / n;
 // std::cout << k << std::endl;
  long long K = bin_pow(2, k);
  // if(I % n == 0) {
  //   K--;
  // }
  //if(k == 0) K = 1;
  //std::cout << "K " <<  K << std::endl;

  int need = 9999999, del = 0;

  std::vector<int> s;
  //std::cout << "MP: ";
  for(auto& it : mp) {
    s.push_back(it.second);
    //std::cout << it.second << ' ';
  }
  //std::cout << std::endl;

  std::sort(begin(s), end(s));

  for(long long C = std::max(0ll, K - 3); C <= K + 3; ++C) {
    long long curr_k = log2(C + 1);
    if(curr_k != k) continue;

    //std::cout << C << ' ' << curr_k << std::endl;
    int curr_del = 0, curr_need = 0;
    for(auto& it : s) {
      if((s.size() - curr_del) <= C) break;
      curr_del++;
      // std::cout << it << std::endl;
      curr_need += it;
    }
    //std::cout << curr_need << std::endl;
    need = std::min(need, curr_need);

  }

  std::cout << need << std::endl;

  return 0;
}


#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <set>

long long bin_pow (long long a , long long n) {
  if(n == 0){
    return 1;
  }
  if(n % 2 == 1){
    long long cnt = a * bin_pow(a , n - 1);
    return cnt;
  }
  else {
    long long cnt = bin_pow(a , n / 2);
    return cnt * cnt;
  }
}
int main() {

  long long n, I;
  std::cin >> n >> I;

  I *= 8;

  std::map<long long, int> mp;
  std::vector<long long> a(n);
  for(int i = 0; i < n; ++i) {
    std::cin >> a[i];
    mp[a[i]]++;

  }

  long long k = I / n;
 // std::cout << k << std::endl;
  long long K = bin_pow(2, k);
  if(k == 0) K = 1;
  //std::cout << "K " <<  K << std::endl;

  int need = 0, del = 0;

  std::vector<int> s;
  //std::cout << "MP: ";
  for(auto& it : mp) {
    s.push_back(it.second);
    //std::cout << it.second << ' ';
  }
  //std::cout << std::endl;

  std::sort(begin(s), end(s));

  for(auto& it : s) {
    if((s.size() - del) <= K) break;
    del++;
   // std::cout << it << std::endl;
    need += it;
  }

  std::cout << need << std::endl;

  return 0;
}


#include <algorithm>
#include <iostream>
#include <vector>
#include <cmath>
#include <map>
#include <set>

long long bin_pow (long long a , long long n) {
  if(n == 0){
    return 1;
  }
  if(n % 2 == 1){
    long long cnt = a * bin_pow(a , n - 1);
    return cnt;
  }
  else {
    long long cnt = bin_pow(a , n / 2);
    return cnt * cnt;
  }
}
int main() {

  long long n, I;
  std::cin >> n >> I;

  I *= 8;

  std::map<long long, int> mp;
  std::vector<long long> a(n);
  for(int i = 0; i < n; ++i) {
    std::cin >> a[i];
    mp[a[i]]++;

  }

  long long k = I / n;
 // std::cout << k << std::endl;
  long long K = bin_pow(2, k);
  if(I % n == 0) {
    K--;
  }
  //if(k == 0) K = 1;
  //std::cout << "K " <<  K << std::endl;

  int need = 9999999, del = 0;

  std::vector<int> s;
  //std::cout << "MP: ";
  for(auto& it : mp) {
    s.push_back(it.second);
    //std::cout << it.second << ' ';
  }
  //std::cout << std::endl;

  std::sort(begin(s), end(s));

  for(long long C = std::max(0ll, K - 3); C <= K; ++C) {
    long long curr_k = log2(C);
    if(curr_k != k) continue;

    //std::cout << C << ' ' << curr_k << std::endl;
    int curr_del = 0, curr_need = 0;
    for(auto& it : s) {
      if((s.size() - curr_del) <= C) break;
      curr_del++;
      // std::cout << it << std::endl;
      curr_need += it;
    }
    //std::cout << curr_need << std::endl;
    need = std::min(need, curr_need);

  }

  std::cout << need << std::endl;

  return 0;
}


#include <algorithm>
#include <iostream>
#include <vector>
#include <cmath>
#include <map>

long long bin_pow (long long a , long long n) {
  if(n == 0){
    return 1;
  }
  if(n % 2 == 1){
    long long cnt = a * bin_pow(a , n - 1);
    return cnt;
  }
  else {
    long long cnt = bin_pow(a , n / 2);
    return cnt * cnt;
  }
}

signed main() {

  std::size_t n;
  std::cin >> n;

  long long I;
  std::cin >> I;

  std::map<int, int> mp;
  for(std::size_t i = 0; i < n; ++i) {
    int x; std::cin >> x;
    mp[x]++;
  }

  std::vector<int> pref;
  for(const auto& pair : mp) {
    pref.push_back(pair.second);
  }

  std::sort(begin(pref), end(pref));

  for(std::size_t i = 1; i < pref.size(); ++i) {
    pref[i] = pref[i] + pref[i - 1];
  }

  I = I * 8;

  long long k = I / n;

  long long K = bin_pow(2, std::min(k, 20ll));

  if(I % n == 0) K++;

  if(K >= pref.size()) {
    std::cout << 0 << std::endl;
  } else {
    std::cout << pref[pref.size() - K - 1] << std::endl;
  }

  return 0;
}


#include <algorithm>
#include <iostream>
#include <vector>
#include <cmath>
#include <map>

long long bin_pow (long long a , long long n) {
  if(n == 0){
    return 1;
  }
  if(n % 2 == 1){
    long long cnt = a * bin_pow(a , n - 1);
    return cnt;
  }
  else {
    long long cnt = bin_pow(a , n / 2);
    return cnt * cnt;
  }
}

signed main() {

  std::size_t n;
  std::cin >> n;

  long long I;
  std::cin >> I;

  std::map<int, int> mp;
  for(std::size_t i = 0; i < n; ++i) {
    int x; std::cin >> x;
    mp[x]++;
  }

  std::vector<int> pref;
  for(const auto& pair : mp) {
    pref.push_back(pair.second);
  }

  std::sort(begin(pref), end(pref));

  for(std::size_t i = 1; i < pref.size(); ++i) {
    pref[i] = pref[i] + pref[i - 1];
  }

  I = I * 8;

  long long k = I / n;

  long long K = bin_pow(2, k);

  if(I % n == 0) K--;

  if(K >= pref.size()) {
    std::cout << 0 << std::endl;
  } else {
    std::cout << pref[pref.size() - K - 1] << std::endl;
   }

  return 0;
}