#include <bits/stdc++.h>
using namespace std;
const int maxn = 400040, mod = 998244353;
inline int read() {
  int x = 0, f = 0;
  char ch = getchar();
  while (ch < '0' || ch > '9') f |= ch == '-', ch = getchar();
  while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
  return f ? -x : x;
}
int n, I, pr = 1, a[maxn], ans = 1e9, pre[maxn];
int main() {
  n = read();
  I = read();
  for (int i = (1); i <= (n); i++) a[i] = read();
  sort(a + 1, a + n + 1);
  I = I * 8 / n;
  while (I && pr <= n) I--, pr *= 2;
  pr = min(pr, n);
  pre[1] = 1;
  for (int i = (2); i <= (n); i++) pre[i] = pre[i - 1] + (a[i] != a[i - 1]);
  for (int i = (1); i <= (n); i++) {
    int x = lower_bound(pre + 1, pre + n + 1, pre[i] + pr) - pre - 1;
    ans = min(ans, i - 1 + n - x);
  }
  printf("%d\n", ans);
}
