#include <bits/stdc++.h>
using namespace std;
const int N = 4e5 + 5;
int n, I, a[N];
map<int, int> mp;
int cnt, buk[N];
int sum[N];
template <typename t>
t &read(t &r);
int main(void) {
  read(n), read(I);
  int tot = n;
  for (register int i = (1); i <= (n); i += (1)) {
    read(a[i]);
    if (mp[a[i]])
      tot--, mp[a[i]]++;
    else
      mp[a[i]]++, buk[++cnt] = a[i];
  }
  int lgk = 8 * I / n, K;
  for (register int i = (n); i >= (0); i -= (1)) {
    int t = ceil(log2(i));
    if (t <= lgk) {
      K = i;
      break;
    }
  }
  if (tot <= K) {
    puts("0");
    return 0;
  }
  sort(buk + 1, buk + cnt + 1);
  for (register int i = (1); i <= (cnt); i += (1))
    sum[i] = sum[i - 1] + mp[buk[i]];
  int ch = tot - K, ans = n;
  for (register int i = (0); i <= (ch); i += (1)) {
    int pre = sum[i];
    int aft = sum[cnt] - sum[cnt - ch + i];
    ans = min(ans, pre + aft);
  }
  printf("%d\n", ans);
  return 0;
}
template <typename t>
t &read(t &r) {
  char c;
  int f = 1;
  while (!isdigit(c = getchar()))
    if (c == '-') f = -1;
  r = c ^ '0';
  while (isdigit(c = getchar())) r = r * 10 + (c ^ '0');
  return r *= f;
}
