#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, I;
  cin >> n >> I;
  I = I * 8;
  vector<int> arr(n);
  for (int i = 0; i < n; i++) cin >> arr[i];
  sort(arr.begin(), arr.end());
  map<int, int> mp;
  int distinct = 0, ans = INT_MAX;
  int j = 0;
  for (int i = 0; i < n; i++) {
    mp[arr[i]]++;
    if (mp[arr[i]] == 1) distinct++;
    while (I < n * ceil(log2(distinct))) {
      mp[arr[j]]--;
      if (mp[arr[j]] == 0) distinct--;
      j++;
    }
    ans = min(ans, j + n - i - 1);
  }
  cout << ans << endl;
}
