#include <bits/stdc++.h>
using namespace std;
int need(int x) {
  for (int i = 0; i <= 20; ++i) {
    int j = 1 << i;
    if (j >= x) return i;
  }
  return -1;
}
int main() {
  int n, I;
  cin >> n >> I;
  I *= 8;
  vector<int> v(n);
  for (int i = 0; i < n; ++i) {
    cin >> v[i];
  }
  sort(v.begin(), v.end());
  int mn = n, dst = 0;
  map<int, int> fr;
  auto add = [&](int x) {
    fr[x]++;
    if (fr[x] == 1) dst++;
  };
  auto rem = [&](int x) {
    fr[x]--;
    if (fr[x] == 0) dst--;
  };
  int j = n - 1;
  for (int i = n - 1; i >= 0; --i) {
    add(v[i]);
    while (j >= i && n * need(dst) > I) rem(v[j]), j--;
    mn = min(mn, i + n - j - 1);
  }
  cout << mn;
}
