#include <bits/stdc++.h>
using namespace std;
int n, l, last, V[400005], nr;
vector<int> A;
int getBits(int x) {
  if (x == 1) return 0;
  int l = ceil(log2(x));
  return l;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> l;
  l *= 8;
  for (int i = 1; i <= n; i++) {
    cin >> V[i];
  }
  sort(V + 1, V + n + 1);
  last = V[1];
  nr = 1;
  for (int i = 2; i <= n; i++) {
    if (V[i] == last) {
      nr++;
    } else {
      A.push_back(nr);
      nr = 1;
      last = V[i];
    }
  }
  A.push_back(nr);
  int dif = 1;
  int tot = A[0];
  int minim = 1e9;
  for (int it1 = 0, it2 = 0; it1 < A.size();) {
    int nr_bits = getBits(dif);
    while (n * nr_bits > l && it1 < it2) {
      dif--;
      tot -= A[it1];
      it1++;
      nr_bits = getBits(dif);
    }
    if (n * nr_bits <= l && n - tot < minim) {
      minim = n - tot;
    }
    if (it2 < A.size() - 1) {
      it2++;
      dif++;
      tot += A[it2];
    } else
      break;
  }
  cout << minim;
  return 0;
}
