#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long n, I;
  cin >> n >> I;
  long long arr[n];
  unordered_set<long long> st;
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
    st.insert(arr[i]);
  }
  sort(arr, arr + n);
  long long l = 0, r = 0, maxim = 0;
  long long different = 0, allowed = pow(2, min((long long)20, ((8 * I) / n)));
  unordered_map<long long, long long> s;
  if (allowed >= st.size()) {
    cout << 0 << endl;
    return 0;
  }
  while (r < n) {
    while (r < n && different <= allowed) {
      if (s.find(arr[r]) == s.end()) {
        different++;
        s[arr[r]]++;
      } else
        s[arr[r]]++;
      r++;
    }
    maxim = max(maxim, r - l - 1);
    s[arr[l]]--;
    if (s[arr[l]] == 0) {
      s.erase(arr[l]);
      different--;
    }
    l++;
  }
  cout << n - maxim;
  return 0;
}
