#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long int n, I;
  cin >> n >> I;
  long long int a[n];
  I = 8 * I;
  set<long long int> s;
  for (long long int i = 0; i < n; i++) {
    cin >> a[i];
    s.insert(a[i]);
  }
  long long int x = s.size();
  long long int q = ceil(log2(x));
  if ((n * q) <= I) {
    cout << 0;
  } else {
    long long int bits = I, dis = I;
    long long int ans = n - 1;
    sort(a, a + n);
    long long int l = 1, i = 0, j = 1;
    set<long long int> s;
    s.insert(a[0]);
    unordered_map<long long int, long long int> mp;
    mp[a[0]]++;
    while (j < n) {
      s.insert(a[j]);
      l++;
      mp[a[j]]++;
      long long int z = (long long int)s.size(), z1 = ceil(log2(z));
      if (z1 * n <= dis) {
        ans = min(ans, n - l);
      } else {
        while (i < j) {
          if (mp[a[i]] == 1) {
            s.erase(a[i]);
            mp[a[i]] = 0;
          } else {
            mp[a[i]]--;
          }
          z = (long long int)s.size();
          z1 = ceil(log2(z));
          l--;
          i++;
          if (z1 * n <= dis) {
            ans = min(ans, n - (l));
            break;
          }
        }
      }
      j++;
    }
    cout << ans << endl;
  }
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long int t;
  t = 1;
  while (t--) {
    solve();
  }
}
