#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, m;
  cin >> n >> m;
  m *= 8;
  m /= n;
  m = (1 << min(m, 30LL));
  vector<int> arr(n);
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
  }
  sort(arr.begin(), arr.end());
  vector<int> p(n);
  p[0] = 1;
  for (int i = 1; i < n; i++) {
    if (arr[i] == arr[i - 1]) {
      p[i] = p[i - 1];
    } else {
      p[i] = p[i - 1] + 1;
    }
  }
  int Max = 0;
  int index = 0;
  for (int i = 0; i < n; i++) {
    while (index < n - 1 && p[index + 1] <= p[i] + m - 1) {
      ++index;
    }
    Max = max(Max, index - i + 1);
  }
  cout << n - Max << "\n";
  return 0;
}
