#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const double eps = 1e-9;
const int maxn = 4e5 + 5;
long long n, a[maxn], b[maxn];
long long pre[maxn], suf[maxn];
long long pw(long long a, long long b) {
  long long ret = 1LL;
  while (b) {
    if (a >= n) return a;
    if (b & 1) {
      ret *= a;
      if (ret >= n) return ret;
    }
    a *= a;
    b >>= 1;
  }
  return ret;
}
int main() {
  scanf("%lld", &n);
  long long I;
  scanf("%lld", &I);
  long long k = (8LL * I) / n;
  long long num = pw(2LL, k);
  for (int i = 1; i <= n; ++i) scanf("%lld", &a[i]);
  sort(a + 1, a + n + 1);
  long long lst = -1, cnt = -1;
  long long tot = 0;
  for (int i = 1; i <= n; ++i) {
    if (a[i] == lst) {
      ++cnt;
      continue;
    }
    if (lst != -1) b[++tot] = cnt;
    lst = a[i];
    cnt = 1LL;
  }
  b[++tot] = cnt;
  if (num >= tot) {
    puts("0");
    return 0;
  }
  pre[0] = suf[tot + 1] = 0;
  for (int i = 1; i <= tot; ++i) {
    pre[i] = pre[i - 1] + b[i];
  }
  for (int i = tot; i >= 1; --i) {
    suf[i] = suf[i + 1] + b[i];
  }
  long long ans = pre[tot];
  for (int i = tot; i >= 1; --i) {
    long long nd = (long long)i - num;
    long long now = suf[i + 1];
    if (nd <= 0) {
      ans = min(ans, now);
      continue;
    }
    now += pre[nd];
    ans = min(ans, now);
  }
  printf("%lld\n", ans);
  return 0;
}
