#include <bits/stdc++.h>
using namespace std;
long long int power(long long int a) {
  long long int pdt = 1, i = 0, t = 20;
  while (i++ < min(a, t)) pdt *= 2;
  return pdt;
}
int main() {
  long long int n, b, i, j, cnt = 0, k = 0;
  cin >> n >> b;
  long long int a[n], c[n];
  b = power((b * 8) / n);
  for (i = 0; i < n; i++) cin >> a[i];
  sort(a, a + n);
  for (i = 0; i < n; i++) {
    j = i + 1;
    while (j < n && a[j] == a[i]) j++;
    cnt++;
    c[k++] = j - i;
    i = j - 1;
  }
  if (cnt < b)
    cout << 0;
  else {
    for (i = 1; i < k; i++) c[i] += c[i - 1];
    long long int maxi = 0;
    for (i = 0; i < k; i++) {
      if (i - b >= 0)
        maxi = max(maxi, c[i] - c[i - b]);
      else if (!(i - b + 1))
        maxi = max(maxi, c[i]);
    }
    cout << n - maxi << endl;
  }
  return 0;
}
