#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, I;
  cin >> n >> I;
  map<long long, long long> mp;
  for (long long i = 0; i < n; i++) {
    long long x;
    cin >> x;
    mp[x]++;
  }
  if (ceil(log2(mp.size())) * n <= I * 8) {
    cout << 0;
    return 0;
  }
  vector<long long> v(mp.size() + 1);
  long long j = 1;
  v[0] = 0;
  for (auto i = mp.begin(); i != mp.end(); i++) {
    v[j] = v[j - 1] + i->second;
    j++;
  }
  long long x = pow(2, (I * 8) / n);
  long long max_int = 0;
  for (long long i = 0; i < v.size() - x; i++) {
    max_int = max(max_int, v[i + x] - v[i]);
  }
  cout << n - max_int;
  return 0;
}
