#include <bits/stdc++.h>
using namespace std;
long long q[500100];
long long down2(long long a) {
  long long re = 0;
  while (a) {
    a /= 2;
    re++;
  }
  return re;
}
int main() {
  long long n, k;
  cin >> n >> k;
  for (long long i = 0; i < n; i++) {
    cin >> q[i];
  }
  sort(q, q + n);
  long long m = 0;
  long long l = 0, r = 0;
  int dif = 0;
  while (r < n) {
    if (n * down2(dif) <= 8 * k) {
      r++;
      m = max(m, r - l);
      if (q[r] != q[r - 1]) dif++;
    } else {
      l++;
      if (q[l] != q[l - 1]) dif--;
    }
  }
  cout << n - m;
}
