#include <bits/stdc++.h>
using namespace std;
const long long MOD = (long long)1e9 + 7;
int n, I, len;
map<int, int> mp;
vector<int> a;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> I;
  a.resize(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    mp[a[i]]++;
  }
  sort(a.begin(), a.end());
  a.resize(unique(a.begin(), a.end()) - a.begin());
  int tmp = (8 * I) / n;
  int sz = a.size();
  int cnt = 0, cur = 1;
  while (1) {
    if (cur >= sz) break;
    cur = cur << 1;
    cnt++;
  }
  if (tmp >= cnt) {
    cout << 0 << "\n";
  } else {
    int ans = 0;
    int pre = 0, z = 0;
    int cnt = 0;
    cnt += mp[a[0]];
    long long L = (1LL << tmp);
    while (1) {
      while (z + 1 < sz && z + 1 - pre + 1 <= L) {
        z++;
        cnt += mp[a[z]];
      }
      ans = max(ans, cnt);
      if (z == sz - 1) break;
      cnt -= mp[a[pre]];
      pre++;
    }
    cout << n - ans << "\n";
  }
  return 0;
}
