#include <bits/stdc++.h>
using namespace std;
const int N = 4e6 + 21;
int a[N], b[N];
int pow(int x) {
  int re = 1, a = 2;
  while (x) {
    if (x % 2) {
      re = re * a;
    }
    a = a * a;
    x /= 2;
  }
  return re;
}
int main() {
  int n, I;
  scanf("%d%d", &n, &I);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
  }
  I = I * 8 / n;
  if (I >= 30) {
    printf("0\n");
    return 0;
  }
  int clar = pow(I);
  sort(a + 1, a + 1 + n);
  int tot = 1, k = 1;
  for (int i = 1; i <= n; i++) {
    if (a[i] == a[k]) {
      b[tot]++;
    } else {
      k = i;
      ++tot;
      b[tot]++;
    }
  }
  if (tot <= clar) {
    printf("0\n");
  } else {
    int ans = 0, tmp;
    for (int i = 1; i <= clar; i++) {
      ans += b[i];
    }
    tmp = ans;
    for (int i = clar + 1; i <= tot; i++) {
      tmp = tmp + b[i] - b[i - clar];
      ans = max(ans, tmp);
    }
    printf("%d\n", n - ans);
  }
  return 0;
}
