#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using piii = pair<int, pii>;
const int inf = 1e9 + 7;
int n, k, a[400005];
map<ll, ll> cnt;
bool check(int x) {
  int tm = log2(x);
  if (x > (1 << tm)) tm++;
  return (tm * n) <= (k * 8);
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie();
  cout.tie();
  cin >> n >> k;
  for (int i = 1; i <= n; i++) cin >> a[i];
  sort(a + 1, a + n + 1);
  int res = inf, diff = 0, j = 1;
  for (int i = 1; i <= n; i++) {
    if (!cnt[a[i]]) diff++;
    cnt[a[i]]++;
    while (!check(diff)) {
      cnt[a[j]]--;
      if (!cnt[a[j]]) diff--;
      j++;
    }
    if (check(diff)) res = min(res, j - 1 + n - i);
  }
  cout << res;
  return 0;
}
