#include <bits/stdc++.h>
using namespace std;
long long power(long long a, long long b, long long n) {
  long long ans = 1;
  while (b) {
    ans *= a;
    if (ans >= n) return n;
    b--;
  }
  return ans;
}
int main() {
  long long n, k;
  cin >> n >> k;
  long long a[n];
  for (long long i = 0; i < n; i++) cin >> a[i];
  sort(a, a + n);
  vector<pair<long long, long long>> freq;
  for (long long i = 0; i < n; i++) {
    long long j = i;
    long long cnt = 0;
    while (j < n && a[i] == a[j]) j++;
    freq.push_back(make_pair(a[i], j - i));
    i = j - 1;
  }
  long long n1 = freq.size();
  long long min_bits = n;
  k *= 8;
  long long low = 0;
  long long high = n;
  while (low <= high) {
    long long mid = (low + high) / 2;
    long long bits = mid * n;
    if (bits <= k) {
      min_bits = mid;
      low = mid + 1;
    } else
      high = mid - 1;
  }
  long long min_nums = power(2, min_bits, n);
  long long ans = n;
  long long sum = 0;
  for (long long i = 0; i < min(n1, min_nums); i++) {
    sum += freq[i].second;
  }
  ans = min(ans, n - sum);
  long long j = 0;
  for (long long i = min(n1, min_nums); i < n1; i++) {
    sum += freq[i].second - freq[j].second;
    j++;
    ans = min(ans, n - sum);
  }
  cout << ans;
  return 0;
}
