#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, i, j, l = 0;
  cin >> n >> m;
  m = m * 8;
  int a[n], cnt[n + 1];
  memset(cnt, 0, sizeof(cnt));
  for (i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a, a + n);
  j = a[0];
  cnt[l]++;
  for (i = 1; i < n; i++) {
    if (a[i] == j) {
      cnt[l]++;
      continue;
    }
    l++;
    j = a[i];
    cnt[l]++;
  }
  l++;
  long long k;
  j = m / n;
  j = min(30, j);
  k = (1 << j);
  if (l <= k) {
    cout << "0\n";
    return 0;
  }
  int sum = 0, maxm;
  for (i = 0; i < k; i++) {
    sum = sum + cnt[i];
  }
  maxm = sum;
  for (i = k; i < l; i++) {
    sum = sum - cnt[i - k] + cnt[i];
    if (sum > maxm) maxm = sum;
  }
  cout << n - maxm << endl;
}
