#include <bits/stdc++.h>
using namespace std;
long long arr[400009];
void solve() {
  int n, I;
  cin >> n >> I;
  vector<int> elems;
  unordered_map<int, int> umap;
  for (int i = 1; i <= n; i++) {
    int x;
    cin >> x;
    if (umap[x] == 0) elems.push_back(x);
    umap[x]++;
  }
  long long ans = 0;
  for (int i = 0; i <= (int)elems.size() - 1; i++) ans += umap[elems[i]];
  if ((long long)n * (long long)ceil(log2((int)elems.size())) <=
      (long long)I * 8) {
    cout << 0;
    return;
  }
  int savNum = pow(2, min(20, (I * 8) / n));
  sort(elems.begin(), elems.end());
  int res = 0;
  arr[0] = umap[elems[0]];
  for (int i = 1; i <= (int)elems.size() - 1; i++) {
    arr[i] = arr[i - 1] + umap[elems[i]];
  }
  for (int i = 0; i <= (int)elems.size() - savNum; i++) {
    res = max((long long)res, arr[i + savNum - 1] - arr[i] + umap[elems[i]]);
  }
  cout << ans - res;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ;
  int t;
  t = 1;
  for (int i = 1; i <= t; i++) {
    solve();
  }
  return 0;
}
