#include<bits/stdc++.h>
using namespace std ;
#define Fors(n) for(int i=1;i<=n;i++)
#define For(n) for(i=0;i<n;i++)
#define ll long long
#define vint(s) vector<int> s
#define pb(x) push_back(x)
#define mpair(x,y) make_pair(x,y)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
bool compare(std::pair<long long, ll> i, pair<ll, ll> j) {
return i.second > j.second;
}
ll x=0,y=0,n=0,i=0;
int main(){
IOS;
ll I;
// inputs n & I n --> the length of the array
// I --> the size of the disk in bytes
cin >> n >> I;
I *= 8; // bytes --> bits
map<ll, ll> mp;
set<ll> s;
ll a[n+1];
ll k = (I/n );
ll K = 1; // number of digits I can accomodate
if (k > 28){
K = (1<<28);
}
else{
K = (1<<k);
}
//cout << K;
// Loop 0 - (n-1)
For (n){
cin >> a[i];
mp[a[i]]++; // map <ll, ll>
s.insert(a[i]); // s is set<long long>
}
// Logic if the given space is greater than current distinct integers
// then no element need to be change hence answer = 0;
if (s.size() <= K){
cout << "0" << endl;
return 0;
}
s.clear();
vector <pair <ll, ll>> v; // vector pair
// below loop only pshes the map mp's values in vector
// v.push_back({map.key,map.value})
ll pre[n+2];
pre[0] = 0;
ll l = 1;
for (auto it = mp.begin();it!=mp.end();it++){
ll f,ss;
f = it->first ;
ss = it->second ;
pre[i] = pre[i-1]+ss;
l++;
}
ll ans = 0;
// we sort vector so according to their second values of pair
// so that elemnt has maximum number of occurence come first
//sort(v.begin(),v.end(),compare);
// In the below loop all we do is to count occurences of
// the elemnts we can accomodate
// we can only accomodate maxium K distinct numbers
for (i = 0; i < l-K; i++){
ans = max(ans,pre[i+K]-pre[i])
}
// answer is the numer of elemnts need to be changed is n-ans
cout << abs(n-ans) << endl;
return 0;
}
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KdXNpbmcgbmFtZXNwYWNlIHN0ZCA7CiNkZWZpbmUgRm9ycyhuKSBmb3IoaW50IGk9MTtpPD1uO2krKykKI2RlZmluZSBGb3IobikgZm9yKGk9MDtpPG47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