#include <bits/stdc++.h>
using namespace std;
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  int n, m;
  cin >> n >> m;
  m *= 8;
  m /= n;
  m = min(m, 30);
  vector<int> a(n);
  for (int i = 0; i < n; ++i) cin >> a[i];
  sort(a.begin(), a.end());
  vector<pair<int, int> > v(1, pair<int, int>(a[0], 1));
  for (int i = 1; i < n; ++i) {
    if (a[i] == v.back().first)
      ++v.back().second;
    else
      v.emplace_back(a[i], 1);
  }
  int k = min((int)v.size(), 1 << m);
  vector<int> s(v.size() + 1);
  for (int i = 0; i < (int)v.size(); ++i) {
    s[i + 1] = s[i] + v[i].second;
  }
  int res = n;
  for (int i = 0; i + k <= (int)v.size(); ++i) {
    res = min(res, s[i] + (s.back() - s[i + k]));
  }
  cout << res << endl;
  return 0;
}
