#include <bits/stdc++.h>
using namespace std;
const int maxn = 400 * 1000 + 10, INF = 1 * 1000 * 1000 * 1000 + 10;
int n, I, k, tmp, ans, ted[maxn], a[maxn];
vector<int> vec;
int main() {
  ios::sync_with_stdio(0);
  cin.tie();
  cin >> n >> I;
  k = I * 8 / n;
  ans = n;
  tmp = -1;
  for (int i = 0; i < n; i++) cin >> a[i];
  if (k >= 20) {
    cout << 0;
    return 0;
  }
  sort(a, a + n);
  a[n] = INF;
  for (int i = 0; i < n; i++) {
    if (a[i] != a[i + 1]) {
      vec.push_back(i - tmp);
      tmp = i;
      ted[(((int)vec.size()))] = ted[(((int)vec.size())) - 1] + vec.back();
    }
  }
  for (int i = 0; i < (((int)vec.size())); i++) {
    tmp = ted[i];
    if (i + (1 << k) < (((int)vec.size())))
      tmp += ted[(((int)vec.size()))] - ted[i + (1 << k)];
    ans = min(ans, tmp);
  }
  cout << ans;
  return 0;
}
