#include <bits/stdc++.h>
using ll = long long int;
ll find_max_distinct_values(int n, ll s_bits) {
  ll log_max_distinct_values = s_bits / n;
  if (log_max_distinct_values > 60) {
    return 1LL << 60;
  }
  return 1LL << log_max_distinct_values;
}
template <typename Iterator>
std::size_t count_unique(Iterator first, Iterator last) {
  if (first == last) {
    return 0;
  }
  std::size_t result = 1;
  Iterator prev = first++;
  while (first != last) {
    if (*prev != *first) {
      ++result;
    }
    prev = first++;
  }
  return result;
}
int main() {
  int n;
  ll s_bytes;
  ll s_bits;
  std::cin >> n >> s_bytes;
  s_bits = s_bytes * 8;
  ll max_distinct_values = find_max_distinct_values(n, s_bits);
  std::vector<int> a(n);
  for (int i = 0; i < n; ++i) {
    std::cin >> a[i];
  }
  std::sort(a.begin(), a.end());
  int distinct_values = count_unique(a.begin(), a.end());
  if (distinct_values <= max_distinct_values) {
    std::cout << 0 << std::endl;
    return 0;
  }
  int first = 0;
  int last = n - 1;
  while (distinct_values > max_distinct_values) {
    if (a[last] != a[last - 1]) {
      distinct_values--;
    }
    --last;
  }
  int best_result = last - first + 1;
  for (first = 1; first < n; ++first) {
    if (a[first] != a[first - 1]) {
      if (last != n - 1) {
        ++last;
        while (last != n - 1 && a[last] == a[last + 1]) {
          ++last;
        }
      }
    }
    best_result = std::max(last - first + 1, best_result);
  }
  std::cout << n - best_result << std::endl;
}
