#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-10;
const int INF = 1000000000;
const int maxn = 400000 + 10;
int n, I, a[maxn];
map<int, int> m;
int main() {
  cin >> n >> I;
  for (int t = (0); t < (n); ++t) scanf("%d", a + t);
  int k = 8 * I / n;
  if (n * k <= 8 * I) {
    if (n * (k + 1) <= 8 * I) ++k;
  } else {
    --k;
  }
  int K;
  if (k >= 19) {
    cout << 0;
    return 0;
  } else
    K = 1 << k;
  sort(a, a + n);
  int r = -1;
  int ans = INF;
  for (int l = (0); l < (n); ++l) {
    while (m.size() <= K) {
      ++r;
      if (r == n) {
        ans = min(ans, l);
        goto N;
      }
      if (m.count(a[r]))
        ++m[a[r]];
      else
        m[a[r]] = 1;
      if (m.size() == K) ans = min(ans, n - (r - l + 1));
    }
    if (--m[a[l]] == 0) m.erase(m.find(a[l]));
  }
N:;
  cout << max(ans, 0);
}
