#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) {
  if (!b) return a;
  return gcd(b, a % b);
}
long long fpow(long long x, long long y, long long mod) {
  long long ans = 1ll;
  for (; y; y >>= 1) {
    if (y & 1) ans = ans * x % mod;
    x = x * x % mod;
  }
  return ans;
}
const long long maxd = 4e5 + 10;
long long a[maxd], b[maxd], tot;
long long log(long long x) {
  long long tot = 0, now = 1ll;
  while (now < x) {
    now *= 2;
    tot++;
  }
  return tot;
}
int main() {
  long long n, m;
  scanf("%lld %lld", &n, &m);
  ;
  m *= 8;
  for (long long i = 1; i <= n; i++) scanf("%lld", &a[i]);
  sort(a + 1, a + 1 + n);
  a[n + 1] = -1;
  long long now = 0ll;
  for (long long i = 1; i <= n; i++) {
    now++;
    if (a[i] != a[i + 1]) {
      b[++tot] = now, now = 0;
    }
  }
  long long ans = 1e9, j = 0;
  for (long long i = 0; i < tot; i++) {
    now -= b[i];
    while (j + 1 <= tot && log((j + 1) - i) * (n) <= m) now += b[++j];
    ans = min(ans, n - now);
  }
  printf("%lld\n", ans);
  return 0;
}
