#include <bits/stdc++.h>
using namespace std;
const long long maxn = 4e5 + 5;
long long n, I, a[maxn], k = 1, l = 1, sum = 0, r = 0;
signed main() {
  scanf("%lld %lld", &n, &I);
  I = (I << 3) / n;
  for (long long j = 1; j <= I; j++) {
    k <<= 1;
    if (k >= n) {
      puts("0");
      return 0;
    }
  }
  for (long long i = 1; i <= n; i++) scanf("%lld", &a[i]);
  sort(a + 1, a + n + 1);
  a[0] = -1;
  long long ans = n - 1;
  while (r < n) {
    while (r < n && (sum < k || ((a[r] == a[r + 1]) && k == sum)))
      r++, sum += (a[r] != a[r - 1]);
    ans = min(ans, n - (r - l + 1));
    while (l < r && a[l] == a[l + 1]) l++;
    l++, sum--;
  }
  printf("%lld\n", min(ans, n - (r - l + 1)));
  return 0;
}
