#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n, I;
  cin >> n >> I;
  I *= 8;
  long long a[n];
  for (long long i = 0; i < n; i++) cin >> a[i];
  map<long long, long long> mapu;
  for (long long i = 0; i < n; i++) mapu[a[i]]++;
  vector<long long> output;
  for (auto it = mapu.begin(); it != mapu.end(); it++)
    output.push_back(it->second);
  long long loda = I / n;
  long long poi;
  if (loda > 18)
    poi = output.size();
  else {
    poi = pow(2, loda);
    if (poi > output.size()) poi = output.size();
  }
  long long maxisum = 0;
  long long summi[output.size() + 1];
  for (long long i = 0; i <= output.size(); i++) summi[i] = 0;
  for (long long i = 1; i <= output.size(); i++) {
    summi[i] = summi[i - 1] + output[i - 1];
  }
  for (long long i = 1; i <= output.size() - poi + 1; i++) {
    long long loli = summi[i + poi - 1] - summi[i - 1];
    if (loli > maxisum) maxisum = loli;
  }
  cout << n - maxisum;
  return 0;
}
