#include <bits/stdc++.h>
int main() {
  int n, I;
  scanf("%d%d", &n, &I);
  int w = 1 << std::min(20, (I * 8 / n));
  std::vector<int> a(n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }
  std::sort(a.begin(), a.end());
  std::vector<int> u, c;
  for (int v : a) {
    if (!u.empty() && u.back() == v) {
      c.back()++;
    } else {
      u.push_back(v);
      c.push_back(1);
    }
  }
  if (w >= c.size()) {
    printf("0\n");
    return 0;
  }
  int ans = n;
  int cur = 0;
  for (int i = 0; i < w - 1; i++) {
    cur += c[i];
  }
  for (int i = w - 1; i < c.size(); i++) {
    cur += c[i];
    if (i - w >= 0) {
      cur -= c[i - w];
    }
    ans = std::min(ans, n - cur);
  }
  printf("%d\n", ans);
  return 0;
}
