#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, ans = 0, k, mx = 0;
  cin >> n >> k;
  k = (8 * k) / n;
  k = (1 << (min(20ll, k)));
  vector<long long int> arr, pref;
  map<long long int, long long int> list;
  for (int x = 0; x < n; x++) {
    int a;
    cin >> a;
    if (list.find(a) == list.end())
      list.insert({a, 1});
    else
      list[a]++;
  }
  for (auto it = list.begin(); it != list.end(); it++)
    arr.push_back(it->second);
  pref.resize(arr.size());
  pref[0] = arr[0];
  for (int x = 1; x < arr.size(); x++) pref[x] = arr[x] + pref[x - 1];
  if (pref.size() > k) {
    mx = pref[k - 1];
    for (int x = k; x < pref.size(); x++) mx = max(mx, pref[x] - pref[x - k]);
    cout << pref[pref.size() - 1] - mx << endl;
  } else
    cout << 0 << endl;
}
