#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long n, k;
  cin >> n >> k;
  long long a[n];
  map<long long, long long> m;
  vector<pair<long long, long long> > p;
  set<long long> s;
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
    auto x = m.find(a[i]);
    if (x == m.end()) {
      m.insert({a[i], 1});
    } else {
      int yo = x->second;
      m.erase(x);
      m.insert({a[i], yo + 1});
    }
    s.insert(a[i]);
  }
  sort(a, a + n);
  int dis = s.size();
  int l = log2(dis);
  if (pow(2, l) != dis) {
    l++;
  }
  if (l * n <= k * 8) {
    cout << 0;
  } else {
    vector<long long> coun;
    for (auto i : m) {
      coun.push_back(i.second);
      p.push_back({i.first, i.second});
    }
    sort(p.begin(), p.end());
    long long r = k * 8 / n;
    long long y = pow(2, r);
    long long ans = 0, yo = 0;
    for (long long i = 0; i < y; i++) {
      ans += p[i].second;
    }
    yo = ans;
    for (long long i = 1; i <= p.size() - y; i++) {
      long long temp = yo - p[i - 1].second + p[i + y - 1].second;
      yo = temp;
      ans = max(ans, yo);
    }
    cout << n - ans;
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  solve();
  return 0;
}
