#include <bits/stdc++.h>
using namespace std;
inline long long mlog(long long x) {
  long long res = 0, d = 1;
  while (d < x) {
    d <<= 1;
    ++res;
  }
  return res;
}
int32_t main() {
  ios_base ::sync_with_stdio(false);
  long long n, I;
  cin >> n >> I;
  I <<= 3;
  vector<long long> a(n);
  map<long long, long long> m;
  for (auto& i : a) {
    cin >> i;
    ++m[i];
  }
  vector<pair<long long, long long>> b;
  for (auto& i : m) {
    b.push_back(i);
    if (b.size() > 1) {
      b[b.size() - 1].second += b[b.size() - 2].second;
    }
  }
  long long ans = 1;
  for (long long i = 0; i < b.size(); ++i) {
    long long l = i, r = b.size() - 1;
    while (l + 1 < r) {
      long long mid = l + r >> 1;
      long long temp_unique_number = mid - i + 1;
      if (n * mlog(temp_unique_number) <= I) {
        l = mid;
      } else {
        r = mid - 1;
      }
    }
    {
      long long temp_number =
          i > 0 ? b[r].second - b[i - 1].second : b[r].second;
      long long temp_unique_number = r - i + 1;
      if (n * mlog(temp_unique_number) <= I && temp_number > ans) {
        ans = temp_number;
      }
    }
    {
      long long temp_number =
          i > 0 ? b[l].second - b[i - 1].second : b[l].second;
      long long temp_unique_number = l - i + 1;
      if (n * mlog(temp_unique_number) <= I && temp_number > ans) {
        ans = temp_number;
      }
    }
  }
  cout << n - ans;
}
