#include <bits/stdc++.h>
using namespace std;
int n;
int m;
int a[400000 + 10];
int g[400000 + 10];
long long sum[400000 + 10];
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);
  sort(a, a + n);
  int cnt = 0;
  int pre = -1;
  for (int i = 0; i < n; i++) {
    if (a[i] > pre) cnt++, pre = a[i];
    g[cnt]++;
  }
  double k = (m * 8.0) / ((double)n);
  int ans = 1;
  for (int i = 0; i < (int)k; i++) {
    ans = ans * 2;
    if (ans >= cnt) {
      break;
    }
  }
  if (ans >= cnt) {
    printf("0\n");
    return 0;
  }
  long long res = n;
  for (int i = 1; i <= cnt; i++) {
    sum[i] = sum[i - 1] + (long long)g[i];
  }
  for (int i = ans; i <= n; i++) {
    res = min(res, n - (sum[i] - sum[i - ans]));
  }
  printf("%lld\n", res);
  return 0;
}
