#include <bits/stdc++.h>
using namespace std;
int n, ans, head, tail, a[400005], b[400005];
long long m;
int main() {
  scanf("%d%lld", &n, &m), m = 1 << (min(m * 8ll / n, 30ll));
  for (int i = 1; i <= n; i++) scanf("%d", &b[i]);
  sort(b + 1, b + n + 1);
  for (int i = 1; i <= n; i++)
    a[i] = (b[i] == b[i - 1]) ? a[i - 1] : a[i - 1] + 1;
  head = tail = 1, ans = 1;
  while (tail < n) {
    while (head <= tail && tail < n && a[tail + 1] - a[head] + 1 <= m) tail++;
    ans = max(ans, tail - head + 1), tail++;
    if (tail > n) break;
    while (head <= tail && a[tail] - a[head] + 1 > m) head++;
  }
  printf("%d\n", n - ans);
  return 0;
}
