#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
long long qpow(long long a, long long b) {
  long long res = 1;
  while (b) {
    if (b & 1) res = res * a;
    b >>= 1;
    a = a * a;
  }
  return res;
}
int a[500005];
int main() {
  int n, k;
  cin >> n >> k;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  sort(a + 1, a + n + 1);
  k = 8 * k / n;
  if (k >= ceil(log(n) / log(2))) {
    cout << 0;
    return 0;
  }
  long long q = pow(2, k);
  int min1 = n;
  int sum = 0;
  for (int l = 1, r = 1; r <= n && l <= n;) {
    while (r < n && a[r] == a[r + 1]) r++;
    sum++;
    if (sum == q) {
      min1 = min(min1, n - (r - l + 1)), sum--;
      while (l < n && a[l] == a[l + 1]) l++;
      l++;
    }
    r++;
  }
  if (min1 == n)
    cout << 0;
  else
    cout << min1;
  return 0;
}
