#include <bits/stdc++.h>
using namespace std;
inline int read() {
  register int res = 0, c;
  while (c = getchar(), c < '0' || c > '9')
    ;
  do {
    res = (res * 10) + (c ^ 48);
  } while (c = getchar(), c >= '0' && c <= '9');
  return res;
}
int s[400010];
unordered_map<int, int> times;
int main() {
  int N = read(), I = read(), k = I * 8 / N;
  if (k >= 19) return puts("0"), 0;
  k = (1 << k);
  for (int i = 1; i <= N; i++) s[i] = read();
  sort(s + 1, s + 1 + N);
  int j = 0, ans = 0x3f3f3f3f, kk = 0;
  for (int i = 1; i <= N; i++) {
    while (j < N) {
      register int t = s[j + 1];
      bool test = times[t] == 0;
      if (kk + test <= k) {
        j++;
        times[t]++;
        if (test) kk++;
      } else
        break;
    }
    ans = min(ans, N - j + i - 1);
    if (!--times[s[i]]) {
      kk--;
      times.erase(s[i]);
    }
    if (j == N) break;
  }
  printf("%d\n", ans);
  return 0;
}
