#include <bits/stdc++.h>
using namespace std;
const long long N = 4e6 + 5;
long long n, a[N], b[N], sum[N], I, lim = 1, mx = -1, Ans;
long long read() {
  long long x = 0, f = 1;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    x = (x << 1) + (x << 3) + c - '0';
    c = getchar();
  }
  return f * x;
}
long long qpow(long long x, long long y) {
  long long ret = 1;
  while (y) {
    if (y & 1) ret = ret * x;
    y >>= 1;
    x = x * x;
  }
  return ret;
}
long long LG2(long long x) {
  long long ret = log2(x);
  if (qpow(2, ret) >= x)
    return ret;
  else
    return ret + 1;
}
int main() {
  memset(sum, 0, sizeof(sum));
  memset(a, 0, sizeof(a));
  memset(b, 0, sizeof(b));
  n = read(), I = read();
  for (register long long i = (1); i <= (n); i++) a[i] = read();
  sort(a + 1, a + n + 1);
  a[0] = -1;
  for (register long long i = (1); i <= (n); i++) {
    if (a[i] != a[i - 1])
      b[++b[0]] = 1;
    else
      b[b[0]]++;
  }
  for (register long long i = (2); i <= (b[0]); i++) {
    if (LG2(i) * n <= 8 * I)
      lim = i;
    else
      break;
  }
  if (lim >= b[0])
    printf("0\n");
  else {
    for (register long long i = (1); i <= (b[0]); i++)
      sum[i] = sum[i - 1] + b[i];
    for (register long long i = (lim); i <= (b[0]); i++)
      mx = max(mx, sum[i] - sum[i - lim]);
    Ans = sum[b[0]] - mx;
    printf("%lld\n", Ans);
  }
  return 0;
}
