#include <bits/stdc++.h>
using namespace std;
long long ara[400005], cnt[2][400005];
map<long long, long long> mp;
vector<long long> v;
long long check(long long n, long long I) {
  memset(cnt, 0, sizeof cnt);
  for (long long i = 1; i <= v.size(); i++) {
    cnt[0][i] += (cnt[0][i - 1] + mp[v[i - 1]]);
  }
  long long c = 1;
  for (long long i = ((long long)v.size()); i >= 1; i--) {
    cnt[1][c] += (cnt[1][c - 1] + mp[v[i - 1]]);
    c++;
  }
  long long ans = 1e18 + 19;
  for (long long i = 0; i < 24; i++) {
    long long k = min((1LL << i), ((long long)v.size()));
    c = v.size();
    k = c - k;
    if (i * n <= 8 * I) {
      for (long long j = 0; j <= k; j++) {
        long long l = k - j;
        ans = min(ans, cnt[0][j] + cnt[1][l]);
      }
    }
  }
  mp.clear();
  v.clear();
  return ans;
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long n, I;
  while (cin >> n >> I) {
    for (long long i = 0; i < n; i++) {
      cin >> ara[i];
      if (!mp[ara[i]]) {
        v.push_back(ara[i]);
      }
      mp[ara[i]]++;
    }
    sort(v.begin(), v.end());
    cout << check(n, I) << endl;
  }
  return 0;
}
