#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, s;
  cin >> n >> s;
  int a[n];
  map<int, int> m;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    m[a[i]]++;
  }
  int dis = m.size();
  auto i = m.begin();
  vector<int> v;
  while (i != m.end()) {
    v.push_back(i->second);
    i++;
  }
  s = s * 8;
  s = s / n;
  if (s > 20) {
    cout << 0;
    return 0;
  }
  s = pow(2, s);
  if (s >= dis) {
    cout << 0;
    return 0;
  }
  long long int sum = 0;
  long long int summi[v.size() + 1];
  summi[0] = 0;
  for (int i = 1; i <= v.size(); i++) {
    summi[i] = 0;
    summi[i] = summi[i - 1] + v[i - 1];
  }
  for (int i = 1; i <= v.size() - s + 1; i++) {
    long long int kkk = summi[i + s - 1] - summi[i - 1];
    if (sum < kkk) sum = kkk;
  }
  cout << n - sum;
}
