#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, ii;
  scanf("%d %d", &n, &ii);
  ii *= 8;
  ii /= n;
  int maxdistinct_b = (int)ceil(log2(n));
  ii = min(ii, maxdistinct_b + 5);
  long long num_distinct = ((1ll << (ii)));
  map<int, int> m;
  for (int i = 0; i < n; ++i) {
    int x;
    scanf("%d", &x);
    m[x]++;
  }
  vector<int> v;
  for (auto &x : m) {
    v.push_back(x.second);
  }
  vector<int> accu;
  accu.push_back(v[0]);
  for (int i = 1; i < v.size(); ++i) {
    accu.push_back(accu.back() + v[i]);
  }
  long long quero_tirar = m.size() - num_distinct;
  if (quero_tirar <= 0) {
    printf("0\n");
    return 0;
  }
  int ans = accu[quero_tirar - 1];
  int cont = 0;
  for (int i = v.size() - 1, j = 1; i >= 0 && (quero_tirar - 1 - j >= 0);
       --i, j++) {
    cont += v[i];
    ans = min(ans, cont + accu[quero_tirar - 1 - j]);
  }
  printf("%d\n", ans);
}
