#include <bits/stdc++.h>
using namespace std;
const int MX = 400005;
long long n, I, a[MX];
map<int, int> mp;
long long my_log2(long long n) { return ceil(log2(n)); }
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> I;
  I = I * 8;
  for (long long i = 0; i < n; ++i) cin >> a[i];
  sort(a, a + n);
  long long i = 0, j = 0, result = n;
  while (i < n) {
    while (j < n) {
      mp[a[j]]++;
      ++j;
      if (n * my_log2(mp.size()) > I) {
        --j;
        mp[a[j]]--;
        if (!mp[a[j]]) mp.erase(a[j]);
        break;
      }
    }
    result = min(result, i + n - j);
    mp[a[i]]--;
    if (!mp[a[i]]) mp.erase(a[i]);
    ++i;
  }
  cout << result << '\n';
}
