#include <bits/stdc++.h>
using namespace std;
int n, I;
map<int, int> recordings;
int determine_max_unique() {
  for (int unique_num = n; unique_num >= 1; --unique_num) {
    int mem = ceil(log2(unique_num + 0.0));
    mem *= n;
    if (mem > I * 8) continue;
    return unique_num;
  }
  return 1;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> n >> I;
  for (int i = 0; i < n; ++i) {
    int recording;
    cin >> recording;
    ++recordings[recording];
  }
  vector<int> pieces;
  for (const auto &it : recordings) pieces.push_back(it.second);
  int unique_num = determine_max_unique();
  if (pieces.size() <= unique_num) {
    cout << 0 << endl;
    return 0;
  }
  int cumulative = 0;
  for (int i = 0; i < unique_num; ++i) cumulative += pieces[i];
  int max_sum = cumulative;
  for (int j = unique_num, i = 1; j < pieces.size(); ++j, ++i) {
    cumulative -= pieces[i - 1];
    cumulative += pieces[j];
    max_sum = max(max_sum, cumulative);
  }
  cout << (n - max_sum) << endl;
  return 0;
}
